Bläddra i källkod

服务表冗余志愿者名称,和默认展示价格

lsd 3 månader sedan
förälder
incheckning
4e0366eb26

+ 11 - 19
leromro-core/src/main/java/com/leromro/core/controller/VolunteerBaseInfoController.java

@@ -1,30 +1,22 @@
 package com.leromro.core.controller;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
-import com.leromro.core.domain.vo.VolunteerBaseInfoAndCertificationVO;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import com.leromro.common.core.domain.R;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.leromro.common.annotation.Log;
 import com.leromro.common.core.controller.BaseController;
 import com.leromro.common.core.domain.AjaxResult;
+import com.leromro.common.core.domain.R;
+import com.leromro.common.core.page.TableDataInfo;
 import com.leromro.common.enums.BusinessType;
+import com.leromro.common.utils.poi.ExcelUtil;
 import com.leromro.core.domain.VolunteerBaseInfo;
 import com.leromro.core.service.IVolunteerBaseInfoService;
-import com.leromro.common.utils.poi.ExcelUtil;
-import com.leromro.common.core.page.TableDataInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 志愿者基本信息Controller

+ 9 - 0
leromro-core/src/main/java/com/leromro/core/domain/VolunteerService.java

@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.*;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -35,6 +36,10 @@ public class VolunteerService extends BaseEntity
     @ApiModelProperty("志愿者id")
     private Long volunteerId;
 
+    @TableField("volunteer_name")
+    @ApiModelProperty("志愿者名称")
+    private String volunteerName;
+
     @TableField("business_management_id")
     @ApiModelProperty("服务类型id")
     private Long businessManagementId;
@@ -87,6 +92,10 @@ public class VolunteerService extends BaseEntity
     @ApiModelProperty("服务下架时间")
     private Date downTime;
 
+    @TableField("default_price")
+    @ApiModelProperty("默认展示价格(元)")
+    private BigDecimal defaultPrice;
+
     @TableField("del_flag")
     @ApiModelProperty("逻辑删除标识  0:未删除 1:已删除")
     private Integer delFlag;

+ 10 - 1
leromro-core/src/main/java/com/leromro/core/service/IVolunteerCertificationService.java

@@ -1,9 +1,10 @@
 package com.leromro.core.service;
 
-import java.util.List;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.leromro.core.domain.VolunteerCertification;
 
+import java.util.List;
+
 /**
  * 志愿者资质信息Service接口
  * 
@@ -59,4 +60,12 @@ public interface IVolunteerCertificationService extends IService<VolunteerCertif
      * @return 结果
      */
     public int deleteVolunteerCertificationByLVolunteerCertificationId(Long lVolunteerCertificationId);
+
+    /**
+     * 获取志愿者资质信息
+     * @param volunteerId
+     * @param businessManagementId
+     * @return
+     */
+    VolunteerCertification getVounteerCertification(Long volunteerId, Long businessManagementId);
 }

+ 13 - 5
leromro-core/src/main/java/com/leromro/core/service/impl/VolunteerCertificationServiceImpl.java

@@ -1,14 +1,14 @@
 package com.leromro.core.service.impl;
 
-import java.util.List;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.leromro.core.domain.VolunteerCertification;
 import com.leromro.core.mapper.VolunteerCertificationMapper;
-import com.leromro.common.utils.DateUtils;
+import com.leromro.core.service.IVolunteerCertificationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.leromro.core.mapper.VolunteerCertificationMapper;
-import com.leromro.core.domain.VolunteerCertification;
-import com.leromro.core.service.IVolunteerCertificationService;
+
+import java.util.List;
 
 /**
  * 志愿者资质信息Service业务层处理
@@ -93,4 +93,12 @@ public class VolunteerCertificationServiceImpl extends ServiceImpl<VolunteerCert
     {
         return volunteerCertificationMapper.deleteVolunteerCertificationByLVolunteerCertificationId(lVolunteerCertificationId);
     }
+
+    @Override
+    public VolunteerCertification getVounteerCertification(Long volunteerId, Long businessManagementId) {
+        return this.getOne(new LambdaQueryWrapper<VolunteerCertification>()
+                .eq(VolunteerCertification::getVolunteerId, volunteerId)
+                .eq(VolunteerCertification::getBusinessManagementId, businessManagementId)
+        );
+    }
 }

+ 45 - 3
leromro-core/src/main/java/com/leromro/core/service/impl/VolunteerServiceServiceImpl.java

@@ -8,6 +8,8 @@ import com.leromro.common.enums.VolunteerServiceAuditStatusEnum;
 import com.leromro.common.enums.VolunteerServiceStatusEnum;
 import com.leromro.common.exception.ServiceException;
 import com.leromro.common.utils.PageUtils;
+import com.leromro.core.domain.VolunteerBaseInfo;
+import com.leromro.core.domain.VolunteerCertification;
 import com.leromro.core.domain.VolunteerService;
 import com.leromro.core.domain.VolunteerServiceSpec;
 import com.leromro.core.domain.dto.VolunteerServiceApplyDTO;
@@ -16,6 +18,8 @@ import com.leromro.core.domain.dto.VolunteerServiceSpecApplyDTO;
 import com.leromro.core.domain.vo.VolunteerServiceInfoVO;
 import com.leromro.core.domain.vo.VolunteerServiceListVO;
 import com.leromro.core.mapper.VolunteerServiceMapper;
+import com.leromro.core.service.IVolunteerBaseInfoService;
+import com.leromro.core.service.IVolunteerCertificationService;
 import com.leromro.core.service.IVolunteerServiceService;
 import com.leromro.core.service.IVolunteerServiceSpecService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,6 +42,10 @@ public class VolunteerServiceServiceImpl extends ServiceImpl<VolunteerServiceMap
     private VolunteerServiceMapper volunteerServiceMapper;
     @Autowired
     private IVolunteerServiceSpecService volunteerServiceSpecService;
+    @Autowired
+    private IVolunteerBaseInfoService volunteerBaseInfoService;
+    @Autowired
+    private IVolunteerCertificationService volunteerCertificationService;
 
     /**
      * 查询志愿者服务信息记录
@@ -108,18 +116,33 @@ public class VolunteerServiceServiceImpl extends ServiceImpl<VolunteerServiceMap
     @Override
     @Transactional
     public void apply(VolunteerServiceApplyDTO volunteerServiceApplyDTO) {
-        // todo 获取志愿者资质认证信息
+        // 获取志愿者信息
+        VolunteerBaseInfo volunteerBaseInfo = volunteerBaseInfoService.selectVolunteerBaseInfoByLVolunteerBaseInfoId(volunteerServiceApplyDTO.getVolunteerId());
+
+        // 获取志愿者资质认证信息
+        VolunteerCertification volunteerCertification = volunteerCertificationService.getVounteerCertification(volunteerServiceApplyDTO.getVolunteerId(), volunteerServiceApplyDTO.getBusinessManagementId());
 
         // 如果没有认证申请的服务类型,则不能申请
+        if (volunteerCertification == null || !"20".equals(volunteerBaseInfo.getCheckStatus()) ) {
+            throw new ServiceException("请先申请认证");
+        }
+
+        // 获取默认规格
+        List<VolunteerServiceSpecApplyDTO> volunteerServiceSpecApplyList = volunteerServiceApplyDTO.getVolunteerServiceSpecList();
+        VolunteerServiceSpecApplyDTO defaultVolunteerServiceSpecApply = volunteerServiceSpecApplyList.stream().filter(volunteerServiceSpecApply -> volunteerServiceSpecApply.getIsDefault() == 1).findFirst().orElse(null);
+        if (defaultVolunteerServiceSpecApply == null) {
+            throw new ServiceException("请选择默认服务规格");
+        }
 
         // 新增服务记录
         VolunteerService paramForInsert = BeanUtil.copyProperties(volunteerServiceApplyDTO, VolunteerService.class);
+        paramForInsert.setVolunteerName(volunteerBaseInfo.getVolunteerName());
+        paramForInsert.setDefaultPrice(defaultVolunteerServiceSpecApply.getPrice());
         paramForInsert.setApplyTime(new Date());
         paramForInsert.setAuditStatus(VolunteerServiceAuditStatusEnum.PENDING_AUDIT.getCode());
         this.save(paramForInsert);
 
         // 新增服务规格记录
-        List<VolunteerServiceSpecApplyDTO> volunteerServiceSpecApplyList = volunteerServiceApplyDTO.getVolunteerServiceSpecList();
         List<VolunteerServiceSpec> volunteerServiceSpecApplyListForInsert = BeanUtil.copyToList(volunteerServiceSpecApplyList, VolunteerServiceSpec.class);
         // 服务规格记录中,添加服务申请记录id
         volunteerServiceSpecApplyListForInsert.stream().forEach(volunteerServiceSpecApply -> {
@@ -140,11 +163,31 @@ public class VolunteerServiceServiceImpl extends ServiceImpl<VolunteerServiceMap
     @Override
     @Transactional
     public void reapply(Long volunteerServiceId, VolunteerServiceApplyDTO volunteerServiceApplyDTO) {
+        // 获取志愿者信息
+        VolunteerBaseInfo volunteerBaseInfo = volunteerBaseInfoService.selectVolunteerBaseInfoByLVolunteerBaseInfoId(volunteerServiceApplyDTO.getVolunteerId());
+
+        // 获取志愿者资质认证信息
+        VolunteerCertification volunteerCertification = volunteerCertificationService.getVounteerCertification(volunteerServiceApplyDTO.getVolunteerId(), volunteerServiceApplyDTO.getBusinessManagementId());
+
+        // 如果没有认证申请的服务类型,则不能申请
+        if (volunteerCertification == null || !"20".equals(volunteerBaseInfo.getCheckStatus()) ) {
+            throw new ServiceException("请先申请认证");
+        }
+
+        // 获取默认规格
+        List<VolunteerServiceSpecApplyDTO> volunteerServiceSpecApplyList = volunteerServiceApplyDTO.getVolunteerServiceSpecList();
+        VolunteerServiceSpecApplyDTO defaultVolunteerServiceSpecApply = volunteerServiceSpecApplyList.stream().filter(volunteerServiceSpecApply -> volunteerServiceSpecApply.getIsDefault() == 1).findFirst().orElse(null);
+        if (defaultVolunteerServiceSpecApply == null) {
+            throw new ServiceException("请选择默认服务规格");
+        }
+
         // 自动下架服务
         this.downService(Collections.singletonList(volunteerServiceId));
 
         // 修改服务信息,并进入审核中状态。
         VolunteerService paramForUpdate = BeanUtil.copyProperties(volunteerServiceApplyDTO, VolunteerService.class);
+        paramForUpdate.setVolunteerName(volunteerBaseInfo.getVolunteerName());
+        paramForUpdate.setDefaultPrice(defaultVolunteerServiceSpecApply.getPrice());
         paramForUpdate.setVolunteerServiceId(volunteerServiceId);
         paramForUpdate.setApplyTime(new Date());
         paramForUpdate.setAuditStatus(VolunteerServiceAuditStatusEnum.PENDING_AUDIT.getCode());
@@ -154,7 +197,6 @@ public class VolunteerServiceServiceImpl extends ServiceImpl<VolunteerServiceMap
         volunteerServiceSpecService.deleteServiceSpecByVolunteerServiceId(volunteerServiceId);
 
         // 新增服务规格信息
-        List<VolunteerServiceSpecApplyDTO> volunteerServiceSpecApplyList = volunteerServiceApplyDTO.getVolunteerServiceSpecList();
         List<VolunteerServiceSpec> volunteerServiceSpecApplyListForInsert = BeanUtil.copyToList(volunteerServiceSpecApplyList, VolunteerServiceSpec.class);
         // 服务规格记录中,添加服务申请记录id
         volunteerServiceSpecApplyListForInsert.stream().forEach(volunteerServiceSpecApply -> {

+ 2 - 2
leromro-core/src/main/resources/mapper/core/VolunteerServiceMapper.xml

@@ -53,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectServiceListByVolunteerId" resultType="com.leromro.core.domain.vo.VolunteerServiceListVO">
         select a.*,
         defaultSpec.spec_describe as specDescribe,
-        defaultSpec.price as price,
+        a.default_price as price,
         defaultSpec.unit as unit,
         defaultSpec.duration as duration,
         l_business_management.business_tier_name as businessTierName
@@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectServiceList" resultType="com.leromro.core.domain.vo.VolunteerServiceListVO">
         select a.*,
         defaultSpec.spec_describe as specDescribe,
-        defaultSpec.price as price,
+        a.default_price as price,
         defaultSpec.unit as unit,
         defaultSpec.duration as duration,
         l_business_management.business_tier_name as businessTierName