|
@@ -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 -> {
|