yangdamao 2 жил өмнө
parent
commit
7bb0c012ac

+ 1 - 1
zhongzheng-admin/src/main/resources/templates/wordPhone.ftl

@@ -49,7 +49,7 @@
 		<table border="1" class="tabsty">
 			<tr>
 				<td class="strong">姓 名</td>
-				<td>${name}</td>
+				<td>${username}</td>
 				<td class="strong">性别</td>
 				<td>${s}</td>
 				<td class="strong">培训岗位</td>

+ 1 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/base/ProfileTpController.java

@@ -70,7 +70,7 @@ public class ProfileTpController extends BaseController {
      */
     @ApiOperation("学员上传承诺书")
     @PostMapping("/commitment/upload")
-    public AjaxResult<Void> commitmentSealUpload(CommitmentSealBo bo) {
+    public AjaxResult<Void> commitmentSealUpload(@RequestBody CommitmentSealBo bo) {
         ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
         bo.setUserId(loginUser.getUser().getUserId());
         return toAjax(iProfileTpService.commitmentSealUpload(bo) ? 1:0 );

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

@@ -542,6 +542,28 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     }
 
 
+    public static Long getAppointTime(Long millisecond, Integer day) {
+        for (Integer i = 0; i < day; i++) {
+            Long dayAfter = getDayBefore(millisecond, 1);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(timeToDate(dayAfter));
+            int index = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+            String[] weeks = new String[]{"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+
+            if (weeks[index].equals("星期六") || weeks[index].equals("星期天")) {
+                day += 1;
+
+            }
+            //判断当前是否为工作日
+            if (!isWorkingDay(dayAfter)) {
+                day += 1;
+            }
+            millisecond = dayAfter;
+        }
+
+        return millisecond;
+    }
+
     /**
      * 指定时间往前或往后推n天
      *

+ 19 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -31,8 +31,10 @@ import com.zhongzheng.modules.exam.domain.*;
 import com.zhongzheng.modules.exam.service.*;
 import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
 import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
+import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.domain.GoodsCourse;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
+import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsPeriodStatusVo;
 import com.zhongzheng.modules.goods.vo.GoodsPeriodVo;
 import com.zhongzheng.modules.goods.vo.GoodsUserVo;
@@ -127,6 +129,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
 
     @Autowired
     private IUserProfileService iUserProfileService;
+    @Autowired
+    private IGoodsService iGoodsService;
 
 
 
@@ -462,7 +466,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
             if(Validator.isNotEmpty(fullName)){
                 if(fullName.equals("继续教育二级建造师")||fullName.equals("继续教育二级造价师")){
                     goodsUserVo.setErJianErZao(true);
-                }else if (fullName.contains("考前培训施工现场专业人员")){
+                }else if (goodsUserVo.getEducationName().equals("考前培训") && goodsUserVo.getProjectName().equals("施工现场专业人员")){
                     //七大员新考 判断是否提交学员资料
                     int count = iUserProfileService.count(new LambdaQueryWrapper<UserProfile>()
                             .notIn(UserProfile::getStatus, Arrays.asList(3, -1))
@@ -493,6 +497,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
             goodsUserVo.setPeriodPlush(classGradeVo.getPeriodPlush());
             goodsUserVo.setOfficialName(classGradeVo.getOfficialName());
             goodsUserVo.setPeriodWaitTime(classGradeVo.getPeriodWaitTime());
+            goodsUserVo.setOpenQuestion(0);
             Long secLong = 0L;
             Long studyLong = 0L;
             SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
@@ -597,11 +602,24 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
                         goodsUserVo.setBeforeEndTime(examBefore.getBeforeEndTime());
                     }
                 }
+
+                //预约考试是否可以购买题库(该商品没有关联题库且预约考试的时间提前7个工作日)
+                Goods goods = iGoodsService.getById(goodsUserVo.getGoodsId());
+                if (ObjectUtils.isNull(goods.getQuestionGoodsId())){
+                    //没有关联题库
+                    //考试时间往前推7个工作日
+                    Long appointTime = DateUtils.getAppointTime(userSubscribe.getApplySiteExamTime(), 7);
+                    if (DateUtils.getNowTime() < appointTime){
+                        goodsUserVo.setOpenQuestion(1);
+                        goodsUserVo.setQuestionGoodsId(goods.getQuestionGoodsId());
+                    }
+                }
             }
         }
         return goodsUserVos;
     }
 
+
     @Override
     public List<GoodsUserVo> goodsStudyProgressList(CourseQueryBo bo) {
         List<GoodsUserVo> goodsUserVos = baseMapper.goodsStudyProgressList(bo);

+ 92 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java

@@ -1,7 +1,10 @@
 package com.zhongzheng.modules.exam.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.lang.Validator;
+import cn.hutool.extra.template.TemplateException;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -11,6 +14,8 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
+import com.openhtmltopdf.swing.Java2DRenderer;
+import com.openhtmltopdf.util.FSImageWriter;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.type.EncryptHandler;
@@ -31,6 +36,7 @@ import com.zhongzheng.modules.bank.domain.Exam;
 import com.zhongzheng.modules.bank.domain.QuestionBusiness;
 import com.zhongzheng.modules.bank.service.IExamService;
 import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
+import com.zhongzheng.modules.base.bo.UserProfileFit;
 import com.zhongzheng.modules.base.bo.UserProfileQueryBo;
 import com.zhongzheng.modules.base.domain.UserProfile;
 import com.zhongzheng.modules.base.service.IUserProfileService;
@@ -55,6 +61,8 @@ import com.zhongzheng.modules.user.service.IUserService;
 import com.zhongzheng.modules.user.service.IUserSubscribeService;
 import com.zhongzheng.modules.user.vo.UserStudyRecordExport;
 import com.zhongzheng.modules.user.vo.UserVo;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
 import org.apache.commons.io.IOUtils;
 import org.apache.http.entity.ContentType;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -68,6 +76,7 @@ import javax.activation.DataHandler;
 import javax.mail.*;
 import javax.mail.internet.*;
 import javax.mail.util.ByteArrayDataSource;
+import java.awt.image.BufferedImage;
 import java.io.*;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -119,6 +128,11 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
     private IUserProfileService iUserProfileService;
     @Value("${exam.applyDelete}")
     private String EXAM_APPLY_DELETE;
+    @Value("${aliyun.oss.endpoint}")
+    private String ALIYUN_OSS_ENDPOINT;
+
+    @Value("${zhongzheng.profile}")
+    private String ZHONGZHENG_PROFILE;
 
     @Override
     public ExamApplyVo queryById(Long applyId) {
@@ -407,6 +421,26 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
 
     @Override
     public ExamUserApplyVo subscribe(ExamApplyQueryBo bo) {
+        //校验预约学员资料信息
+        UserProfile userProfile = iUserProfileService.getOne(new LambdaQueryWrapper<UserProfile>()
+                .eq(UserProfile::getUserId, bo.getUserId())
+                .eq(UserProfile::getOrderGoodsId, bo.getOrderGoodsId())
+                .eq(UserProfile::getGoodsId, bo.getGoodsId())
+                .eq(UserProfile::getStatus, 1)
+                .eq(UserProfile::getChangeStatus, 1)
+                .last("limit 1"));
+        if (ObjectUtils.isNull(userProfile) || ObjectUtils.isNull(userProfile.getKeyValue())){
+            throw new CustomException("学员资料不完善,请先完善学员资料");
+        }
+        JSONObject jsonObject = JSONObject.parseObject(userProfile.getKeyValue());
+        if (ObjectUtils.isNull(jsonObject.get("commitment_seal"))){
+            throw new CustomException("缺少带有公司印章的承诺书,请先上传!");
+        }
+        JSONObject commitmentSeal = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("commitment_seal")));
+        if (ObjectUtils.isNull(commitmentSeal.get("value"))){
+            throw new CustomException("缺少带有公司印章的承诺书,请先上传!");
+        }
+
         //查询学时通过情况
         Integer countGradePeriod = baseMapper.countGradePeriod(bo);
         if (countGradePeriod < 1) {
@@ -440,7 +474,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         if (ObjectUtils.isNotNull(subscribe)) {
             Long examTime = subscribe.getApplySiteExamTime();
             //向后推15个工作日
-            Long applyEndTime = getApplyEndTime(examTime, 20);
+            Long applyEndTime = getApplyEndTime(examTime, 15);
             if (DateUtils.getNowTime() < applyEndTime){
                 throw new CustomException("成绩审核中,请等待15个工作日后再预约!");
             }
@@ -1153,9 +1187,12 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
                     Goods goods = iGoodsService.getById(userProfile.getGoodsId());
                     Major major = iMajorService.getById(goods.getMajorId());
                     if (ObjectUtils.isNotNull(major)){
-                        JSONObject json = JSONObject.parseObject(userProfile.getKeyValue());
-                        JSONObject sign = JSONObject.parseObject(JSONObject.toJSONString(json.get("commitment_electr_signature")));
-                        handleFile(sign,idCard,toPath,"commitment_electr_signature",major.getCategoryName());
+                        try {
+                            generateCommitment(userProfile.getKeyValue(),toPath,idCard,major.getCategoryName());
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                            throw new CustomException("承诺书生成失败");
+                        }
                     }
                 }
             });
@@ -1185,6 +1222,57 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         return content;
     }
 
+    //生成承诺书
+    private void generateCommitment(String keyValue,String toPath,String idCard,String major)throws IOException {
+        int imgIndex=(int)(Math.random() * 10 );
+        //第一种方式
+        Map<String, String> maps = JSONObject.parseObject(keyValue, Map.class);
+
+        //给模板绑定数据
+        Calendar rightNow = Calendar.getInstance();
+        Map<String, Object> bindingMap = new HashMap<>();
+        bindingMap.put("username", JSONObject.parseObject(String.valueOf(maps.get("name")), UserProfileFit.class).getValue());
+        bindingMap.put("s", JSONObject.parseObject(String.valueOf(maps.get("sex")), UserProfileFit.class).getValue());
+        bindingMap.put("post", JSONObject.parseObject(String.valueOf(maps.get("apply_post")), UserProfileFit.class).getValue());
+        bindingMap.put("idcard", JSONObject.parseObject(String.valueOf(maps.get("idcard")), UserProfileFit.class).getValue());
+        bindingMap.put("phone", JSONObject.parseObject(String.valueOf(maps.get("telphone")), UserProfileFit.class).getValue());
+        bindingMap.put("school", JSONObject.parseObject(String.valueOf(maps.get("school")), UserProfileFit.class).getValue());
+        bindingMap.put("edu", JSONObject.parseObject(String.valueOf(maps.get("education")), UserProfileFit.class).getValue());
+        bindingMap.put("major", JSONObject.parseObject(String.valueOf(maps.get("major")), UserProfileFit.class).getValue());
+        bindingMap.put("cname", JSONObject.parseObject(String.valueOf(maps.get("unit_contact")), UserProfileFit.class).getValue());
+        bindingMap.put("cphone", JSONObject.parseObject(String.valueOf(maps.get("unit_tel")), UserProfileFit.class).getValue());
+        bindingMap.put("image", ALIYUN_OSS_ENDPOINT + "/" + JSONObject.parseObject(String.valueOf(maps.get("commitment_electr_signature")), UserProfileFit.class).getValue());
+        bindingMap.put("y", Convert.toStr(rightNow.get(Calendar.YEAR)));
+        bindingMap.put("m", rightNow.get(Calendar.MONTH) + 1);
+        bindingMap.put("d", rightNow.get(Calendar.DAY_OF_MONTH));
+        bindingMap.put("time", JSONObject.parseObject(String.valueOf(maps.get("graduation_time")), UserProfileFit.class).getValue());
+        bindingMap.put("year", JSONObject.parseObject(String.valueOf(maps.get("working_years")), UserProfileFit.class).getValue());
+        File touch = FileUtil.touch(ZHONGZHENG_PROFILE + imgIndex+"word.html");
+        //默认freemake配置
+        Configuration configuration = new Configuration();
+        configuration.setDefaultEncoding("UTF-8");
+        configuration.setClassForTemplateLoading(this.getClass(), "/templates");
+        Template template = configuration.getTemplate("wordPhone.ftl");
+        Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(touch), "UTF-8"));
+        try {
+            //写入数据
+            template.process(bindingMap, out);
+            out.flush();
+            out.close();
+        } catch (TemplateException | freemarker.template.TemplateException e) {
+            e.printStackTrace();
+        }
+        //将模板输出为图片
+        final Java2DRenderer renderer = new Java2DRenderer(touch, 1000, 1000);
+        final BufferedImage img = renderer.getImage();
+        final FSImageWriter imageWriter = new FSImageWriter();
+        imageWriter.setWriteCompressionQuality(1.0f);
+        String fileName = idCard+"$承诺书$"+major+".jpg";
+        String filePath = toPath+"/"+fileName;
+        imageWriter.write(img, filePath);//输出路径
+
+    }
+
     private void handleFile(JSONObject recentPhotos,String idCard,String toPath,String key,String major){
         try {
             if (ObjectUtils.isNotNull(recentPhotos.get("value"))){

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

@@ -160,7 +160,7 @@ private static final long serialVersionUID=1L;
     /** 班级类型 1基础班 2强化班 3私塾班 */
     private Integer gradeType;
     /** 题库商家ID */
-    private Integer questionMerchantId;
+    private Long questionMerchantId;
     /** 第三方题库商品ID */
-    private Integer questionGoodsId;
+    private Long questionGoodsId;
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsUserVo.java

@@ -418,4 +418,10 @@ public class GoodsUserVo {
 
 	@ApiModelProperty("学员资料是否已提交(七大员):1是 0否")
 	private Integer userProfile;
+
+	@ApiModelProperty("学员是否可以购买题库:1是 0否")
+	private Integer openQuestion;
+
+	@ApiModelProperty("关联题库商品ID")
+	private Long questionGoodsId;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/bo/OrderGoodsAddBo.java

@@ -87,4 +87,6 @@ public class OrderGoodsAddBo {
     private String distributionCode;
     @ApiModelProperty("分销链编码")
     private String distributionLinkCode;
+    @ApiModelProperty("关联的订单商品ID")
+    private Long relevanceId;
 }

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

@@ -845,6 +845,30 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         iGoodsQuestionRelService.save(rel);
     }
 
+
+    private void questionOrderHandle(Long orderGoodsId,Long goodsId) {
+        //第三方题库商品
+        Goods questionGoods = iGoodsService.getById(goodsId);
+        if (ObjectUtils.isNull(questionGoods) || questionGoods.getGoodsType() != 9){
+            //商品类型不符合
+            return;
+        }
+        //添加第三方关联记录
+        QuestionMerchant merchant = iQuestionMerchantService.getById(questionGoods.getQuestionMerchantId());
+        if (ObjectUtils.isNull(merchant)){
+            //商家不存在
+            return;
+        }
+        GoodsQuestionRel rel = new GoodsQuestionRel();
+        rel.setOrderGoodsId(orderGoodsId);
+        rel.setQuestionGoodsId(questionGoods.getGoodsId());
+        rel.setStatus(1);
+        rel.setQuestionDoNum(merchant.getDoNum());
+        rel.setCreateTime(DateUtils.getNowTime());
+        rel.setUpdateTime(DateUtils.getNowTime());
+        iGoodsQuestionRelService.save(rel);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Map<String, String> placeSmallOrder(OrderAddBo bo) {
@@ -934,7 +958,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 payPrice = payPrice.add(goods.getStandPrice());
             }
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
-
+            if (ObjectUtils.isNotNull(g.getRelevanceId())){
+                //购买关联题库商品
+                questionOrderHandle(g.getRelevanceId(),g.getGoodsId());
+            }
             boolean canRepeatBuy = false;
             validUserBeforeBuy(goods, bo.getUserId());
             //判断是否有购买过
@@ -1329,7 +1356,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 payPrice = payPrice.add(goods.getStandPrice());
             }
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
-
+            if (ObjectUtils.isNotNull(g.getRelevanceId())){
+                //购买关联题库商品
+                questionOrderHandle(g.getRelevanceId(),g.getGoodsId());
+            }
             boolean canRepeatBuy = false;
             validUserBeforeBuy(goods, bo.getUserId());
             //判断是否有购买过
@@ -1487,7 +1517,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //暂不计算优惠券
             payPrice = payPrice.add(goods.getStandPrice());
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
-
+            if (ObjectUtils.isNotNull(g.getRelevanceId())){
+                //购买关联题库商品
+                questionOrderHandle(g.getRelevanceId(),g.getGoodsId());
+            }
             boolean canRepeatBuy = false;
             validUserBeforeBuy(goods, bo.getUserId());
             //判断是否有购买过
@@ -1960,6 +1993,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
     //判断视频商品是否购买过且服务期是否过期
     public Long getHaveBuyGoods(Long goodsId, Long userId) {
+        Goods goods = iGoodsService.getById(goodsId);
+        if (goods.getGoodsType() == 9){
+            //七大员题库类商品
+            return null;
+        }
         OrderGoodsQueryBo orderGoodsQueryBo = new OrderGoodsQueryBo();
         orderGoodsQueryBo.setUserId(userId);
         orderGoodsQueryBo.setGoodsId(goodsId);

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

@@ -323,7 +323,8 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
                 BigDecimal cost = getInstTimeSettleCost(item);
                 if (ObjectUtils.isNotNull(cost)){
                     BigDecimal instCost = ObjectUtils.isNotNull(item.getInstCost())?item.getInstCost():BigDecimal.ZERO;
-                    BigDecimal add = item.getOrderCost().add(cost).add(instCost);
+                    BigDecimal orderCost = ObjectUtils.isNotNull(item.getOrderCost())?item.getOrderCost():BigDecimal.ZERO;
+                    BigDecimal add = orderCost.add(cost).add(instCost);
                     item.setOrderCost(add);
                 }
                 //退款审核角色