|
@@ -1,20 +1,21 @@
|
|
|
package com.ylx.massage.service.impl;
|
|
package com.ylx.massage.service.impl;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.LinkedHashSet;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import com.ylx.common.core.domain.AjaxResult;
|
|
|
import com.ylx.common.core.domain.model.LoginUser;
|
|
import com.ylx.common.core.domain.model.LoginUser;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.common.utils.DateUtils;
|
|
import com.ylx.common.utils.DateUtils;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
|
|
+import com.ylx.massage.domain.ContractRecord;
|
|
|
|
|
+import com.ylx.massage.domain.MaProject;
|
|
|
import com.ylx.massage.domain.MaTeProject;
|
|
import com.ylx.massage.domain.MaTeProject;
|
|
|
|
|
+import com.ylx.massage.domain.dto.MaProjectSaveDto;
|
|
|
import com.ylx.massage.domain.dto.MaTechnicianMerchantAddDTO;
|
|
import com.ylx.massage.domain.dto.MaTechnicianMerchantAddDTO;
|
|
|
import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
|
|
import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
|
|
|
import com.ylx.massage.domain.dto.MassageMerchantRecommendDto;
|
|
import com.ylx.massage.domain.dto.MassageMerchantRecommendDto;
|
|
@@ -22,9 +23,13 @@ import com.ylx.massage.domain.vo.MaTechnicianAppAddVo;
|
|
|
import com.ylx.massage.domain.vo.MaTechnicianMerchantDetailVO;
|
|
import com.ylx.massage.domain.vo.MaTechnicianMerchantDetailVO;
|
|
|
import com.ylx.massage.domain.vo.MaTechnicianMerchantListVO;
|
|
import com.ylx.massage.domain.vo.MaTechnicianMerchantListVO;
|
|
|
import com.ylx.massage.domain.vo.MerchantVo;
|
|
import com.ylx.massage.domain.vo.MerchantVo;
|
|
|
|
|
+import com.ylx.massage.mapper.ContractRecordMapper;
|
|
|
|
|
+import com.ylx.massage.mapper.MaProjectMapper;
|
|
|
import com.ylx.massage.mapper.MaTeProjectMapper;
|
|
import com.ylx.massage.mapper.MaTeProjectMapper;
|
|
|
|
|
+import com.ylx.massage.service.TbFileService;
|
|
|
import com.ylx.project.domain.Project;
|
|
import com.ylx.project.domain.Project;
|
|
|
import com.ylx.project.mapper.ProjectMapper;
|
|
import com.ylx.project.mapper.ProjectMapper;
|
|
|
|
|
+import lombok.Data;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -32,6 +37,7 @@ import com.ylx.massage.mapper.MaTechnicianMapper;
|
|
|
import com.ylx.massage.domain.MaTechnician;
|
|
import com.ylx.massage.domain.MaTechnician;
|
|
|
import com.ylx.massage.service.IMaTechnicianService;
|
|
import com.ylx.massage.service.IMaTechnicianService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 技师Service业务层处理
|
|
* 技师Service业务层处理
|
|
@@ -48,7 +54,7 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
private static final int AUDIT_APPROVED = 2;
|
|
private static final int AUDIT_APPROVED = 2;
|
|
|
private static final int NS_STATUS_NOT_ON_DUTY = -1;
|
|
private static final int NS_STATUS_NOT_ON_DUTY = -1;
|
|
|
private static final int DEFAULT_STAT_VALUE = 0;
|
|
private static final int DEFAULT_STAT_VALUE = 0;
|
|
|
- private static final long NOT_DELETED = 0L;
|
|
|
|
|
|
|
+ private static final Integer NOT_DELETED = 0;
|
|
|
private static final String MERCHANT_STATUS_NORMAL = "0";
|
|
private static final String MERCHANT_STATUS_NORMAL = "0";
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -57,9 +63,113 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MaTeProjectMapper maTeProjectMapper;
|
|
private MaTeProjectMapper maTeProjectMapper;
|
|
|
|
|
|
|
|
|
|
+ private MaProjectMapper maProjectMapper;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ProjectMapper projectMapper;
|
|
private ProjectMapper projectMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TbFileService fileService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ContractRecordMapper contractRecordMapper;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 商户入驻申请注册
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param req 申请参数
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void apply(MaTechnicianAppAddVo req) {
|
|
|
|
|
+ String phone = req.getTePhone();
|
|
|
|
|
+ //商户入住前置条件校验
|
|
|
|
|
+ getMaTechnician(req, phone);
|
|
|
|
|
+ MaTechnician maTechnician = new MaTechnician();
|
|
|
|
|
+ BeanUtils.copyProperties(req, maTechnician);
|
|
|
|
|
+ //技师类型默认为真实商户
|
|
|
|
|
+ maTechnician.setTechType(0);
|
|
|
|
|
+ maTechnicianMapper.insert(maTechnician);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 商户入住前置条件校验
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param req
|
|
|
|
|
+ * @param phone
|
|
|
|
|
+ */
|
|
|
|
|
+ private void getMaTechnician(MaTechnicianAppAddVo req, String phone) {
|
|
|
|
|
+ // 1. 判断当前用户是否已入驻
|
|
|
|
|
+ MaTechnician userProfile = getMaTechnician(req);
|
|
|
|
|
+ if (userProfile != null) {
|
|
|
|
|
+ throw new RuntimeException("当前用户已入驻,请勿重复提交");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 判断手机号是否已存在
|
|
|
|
|
+ LambdaQueryWrapper<MaTechnician> queryPhoneWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryPhoneWrapper.eq(MaTechnician::getTePhone, phone);
|
|
|
|
|
+ queryPhoneWrapper.eq(MaTechnician::getIsDelete, 0);
|
|
|
|
|
+ MaTechnician maTechnicianPhone = maTechnicianMapper.selectOne(queryPhoneWrapper);
|
|
|
|
|
+ if (maTechnicianPhone != null) {
|
|
|
|
|
+ throw new RuntimeException("手机号已存在,请更换手机号");
|
|
|
|
|
+ }
|
|
|
|
|
+ //3、判断手机号是否已绑定其他用户
|
|
|
|
|
+ LambdaQueryWrapper<MaTechnician> queryTePhoneWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryTePhoneWrapper.eq(MaTechnician::getTePhone, phone);
|
|
|
|
|
+ queryTePhoneWrapper.eq(MaTechnician::getIsDelete, 0);
|
|
|
|
|
+ queryTePhoneWrapper.eq(MaTechnician::getAuditStatus, 2);
|
|
|
|
|
+ MaTechnician maTechnicianTePhone = maTechnicianMapper.selectOne(queryTePhoneWrapper);
|
|
|
|
|
+ if (maTechnicianPhone != null) {
|
|
|
|
|
+ throw new RuntimeException("手机号已被其他用户绑定,请更换手机号");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断当前用户是否已入驻
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private MaTechnician getMaTechnician(MaTechnicianAppAddVo req) {
|
|
|
|
|
+ LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(MaTechnician::getTePhone, req.getTePhone());
|
|
|
|
|
+ queryWrapper.eq(MaTechnician::getIsDelete, 0);
|
|
|
|
|
+ queryWrapper.eq(MaTechnician::getAuditStatus, 2);
|
|
|
|
|
+ queryWrapper.eq(MaTechnician::getOpenService, req.getOpenService());
|
|
|
|
|
+ MaTechnician userProfile = maTechnicianMapper.selectOne(queryWrapper);
|
|
|
|
|
+ return userProfile;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询商户服务项目列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId 商户id
|
|
|
|
|
+ * @param auditStatus 审核状态
|
|
|
|
|
+ * @return 技师列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<MaProject> selectMaTechnicianListBy(String userId, String auditStatus) {
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<MaProject> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(MaProject::getMerchantId, userId);
|
|
|
|
|
+ queryWrapper.eq(MaProject::getAuditStatus, auditStatus);
|
|
|
|
|
+ return maProjectMapper.selectList(queryWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询服务分类项目列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param typeId 技师类型
|
|
|
|
|
+ * @return 技师列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<Project> selectTechnicianListBy(String typeId) {
|
|
|
|
|
+ LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(Project::getType, typeId);
|
|
|
|
|
+ return projectMapper.selectList(queryWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询技师
|
|
* 查询技师
|
|
|
*
|
|
*
|
|
@@ -148,6 +258,118 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
return rows;
|
|
return rows;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 后台编辑商户
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 商户ID
|
|
|
|
|
+ * @param dto 编辑商户参数
|
|
|
|
|
+ * @param loginUser 当前登录用户
|
|
|
|
|
+ * @return 结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public int updateMerchant(Long id, MaTechnicianMerchantAddDTO dto, LoginUser loginUser) {
|
|
|
|
|
+ if (id == null) {
|
|
|
|
|
+ throw new ServiceException("商户ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ MaTechnician existsMerchant = maTechnicianMapper.selectMerchantById(id.intValue());
|
|
|
|
|
+ if (existsMerchant == null || !NOT_DELETED.equals(existsMerchant.getIsDelete())) {
|
|
|
|
|
+ throw new ServiceException("商户不存在或已删除");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ MerchantProjectSelection selection = checkMerchantAddParam(dto);
|
|
|
|
|
+ String userName = loginUser.getUser().getUserName();
|
|
|
|
|
+
|
|
|
|
|
+ MaTechnician maTechnician = new MaTechnician();
|
|
|
|
|
+ maTechnician.setId(id);
|
|
|
|
|
+ maTechnician.setTeName(dto.getTeName().trim());
|
|
|
|
|
+ maTechnician.setTeNickName(dto.getTeNickName().trim());
|
|
|
|
|
+ maTechnician.setTeSex(dto.getTeSex());
|
|
|
|
|
+ maTechnician.setTePhone(dto.getTePhone().trim());
|
|
|
|
|
+ maTechnician.setOpenService(joinIds(selection.getCategoryIds()));
|
|
|
|
|
+ maTechnician.setTeProject(joinProjectTitles(selection.getProjectIds(), selection.getProjectMap()));
|
|
|
|
|
+ maTechnician.setTechType(dto.getTechType());
|
|
|
|
|
+ maTechnician.setIsRecommend(normalizeSwitchValue(dto.getIsRecommend(), "是否推荐"));
|
|
|
|
|
+ maTechnician.setUpdateBy(userName);
|
|
|
|
|
+ maTechnician.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
+
|
|
|
|
|
+ int rows = maTechnicianMapper.updateMerchantById(maTechnician);
|
|
|
|
|
+ if (rows <= 0) {
|
|
|
|
|
+ throw new ServiceException("编辑商户失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ replaceProjectRelations(id, selection.getProjectIds());
|
|
|
|
|
+ return rows;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 后台上传商户合同文件
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 商户ID
|
|
|
|
|
+ * @param file 合同文件
|
|
|
|
|
+ * @param loginUser 当前登录用户
|
|
|
|
|
+ * @return 上传结果
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public AjaxResult uploadMerchantContract(Integer id, MultipartFile file, LoginUser loginUser) {
|
|
|
|
|
+ if (id == null) {
|
|
|
|
|
+ throw new ServiceException("商户ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (file == null || file.isEmpty()) {
|
|
|
|
|
+ throw new ServiceException("合同文件不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ MaTechnician existsMerchant = maTechnicianMapper.selectMerchantById(id);
|
|
|
|
|
+ if (existsMerchant == null || !NOT_DELETED.equals(existsMerchant.getIsDelete())) {
|
|
|
|
|
+ throw new ServiceException("商户不存在或已删除");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AjaxResult uploadResult = fileService.uploadFile(file);
|
|
|
|
|
+ if (uploadResult == null || uploadResult.isError()) {
|
|
|
|
|
+ String message = uploadResult == null ? "合同文件上传失败" : String.valueOf(uploadResult.get(AjaxResult.MSG_TAG));
|
|
|
|
|
+ throw new ServiceException(message);
|
|
|
|
|
+ }
|
|
|
|
|
+ Object url = uploadResult.get("url");
|
|
|
|
|
+ if (url == null || StringUtils.isBlank(String.valueOf(url))) {
|
|
|
|
|
+ throw new ServiceException("合同文件上传失败,未返回文件地址");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ContractRecord contractRecord = new ContractRecord();
|
|
|
|
|
+ contractRecord.setMerchantId(id);
|
|
|
|
|
+ contractRecord.setContractName(file.getOriginalFilename());
|
|
|
|
|
+ contractRecord.setFileUrl(String.valueOf(url));
|
|
|
|
|
+ contractRecord.setSignTime(DateUtils.getNowDate());
|
|
|
|
|
+ contractRecord.setSignerName(existsMerchant.getTeName());
|
|
|
|
|
+ contractRecord.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
+
|
|
|
|
|
+ int rows = contractRecordMapper.insert(contractRecord);
|
|
|
|
|
+ if (rows <= 0) {
|
|
|
|
|
+ throw new ServiceException("保存合同记录失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ return uploadResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 全量替换商户与服务项目关联关系。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param technicianId 商户ID
|
|
|
|
|
+ * @param projectIds 服务项目ID集合
|
|
|
|
|
+ */
|
|
|
|
|
+ private void replaceProjectRelations(Long technicianId, Set<Long> projectIds) {
|
|
|
|
|
+ if (technicianId == null) {
|
|
|
|
|
+ throw new ServiceException("商户ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ maTeProjectMapper.deleteByTechnicianId(technicianId);
|
|
|
|
|
+ for (Long projectId : projectIds) {
|
|
|
|
|
+ MaTeProject relation = new MaTeProject();
|
|
|
|
|
+ relation.setTeId(technicianId);
|
|
|
|
|
+ relation.setProjectId(projectId);
|
|
|
|
|
+ int rows = maTeProjectMapper.insert(relation);
|
|
|
|
|
+ if (rows <= 0) {
|
|
|
|
|
+ throw new ServiceException("编辑商户服务项目失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 后台查询商户列表
|
|
* 后台查询商户列表
|
|
|
*
|
|
*
|
|
@@ -305,14 +527,14 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
|
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
|
|
- .in(Project::getId, distinctProjectIds)
|
|
|
|
|
- .eq(Project::getIsDelete, 0));
|
|
|
|
|
|
|
+ .in(Project::getId, distinctProjectIds)
|
|
|
|
|
+ .eq(Project::getIsDelete, 0));
|
|
|
if (projects.size() != distinctProjectIds.size()) {
|
|
if (projects.size() != distinctProjectIds.size()) {
|
|
|
throw new ServiceException("服务项目不存在或已删除");
|
|
throw new ServiceException("服务项目不存在或已删除");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Map<Long, Project> projectMap = projects.stream()
|
|
Map<Long, Project> projectMap = projects.stream()
|
|
|
- .collect(Collectors.toMap(project -> project.getId().longValue(), Function.identity(), (left, right) -> left));
|
|
|
|
|
|
|
+ .collect(Collectors.toMap(project -> project.getId().longValue(), Function.identity(), (left, right) -> left));
|
|
|
Set<Integer> projectCategoryIds = new LinkedHashSet<>();
|
|
Set<Integer> projectCategoryIds = new LinkedHashSet<>();
|
|
|
for (Long projectId : distinctProjectIds) {
|
|
for (Long projectId : distinctProjectIds) {
|
|
|
Project project = projectMap.get(projectId);
|
|
Project project = projectMap.get(projectId);
|
|
@@ -352,16 +574,16 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
|
|
|
|
|
private String joinIds(Set<Integer> ids) {
|
|
private String joinIds(Set<Integer> ids) {
|
|
|
return ids.stream()
|
|
return ids.stream()
|
|
|
- .map(String::valueOf)
|
|
|
|
|
- .collect(Collectors.joining(","));
|
|
|
|
|
|
|
+ .map(String::valueOf)
|
|
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String joinProjectTitles(Set<Long> projectIds, Map<Long, Project> projectMap) {
|
|
private String joinProjectTitles(Set<Long> projectIds, Map<Long, Project> projectMap) {
|
|
|
return projectIds.stream()
|
|
return projectIds.stream()
|
|
|
- .map(projectMap::get)
|
|
|
|
|
- .map(Project::getTitle)
|
|
|
|
|
- .filter(StringUtils::isNotBlank)
|
|
|
|
|
- .collect(Collectors.joining(","));
|
|
|
|
|
|
|
+ .map(projectMap::get)
|
|
|
|
|
+ .map(Project::getTitle)
|
|
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -411,4 +633,66 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
|
|
|
return projectMap;
|
|
return projectMap;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取未申请技能列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param typeId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<Project> getNotApplyList(String userId, String typeId) {
|
|
|
|
|
+ LambdaQueryWrapper<MaProject> query = new LambdaQueryWrapper<>();
|
|
|
|
|
+ query.eq(MaProject::getMerchantId, userId);
|
|
|
|
|
+ query.eq(MaProject::getMerchantType, typeId);
|
|
|
|
|
+ List<MaProject> maProjectList = maProjectMapper.selectList(query);
|
|
|
|
|
+ // 获取已申请技能ID集合
|
|
|
|
|
+ List<String> projectIdList = maProjectList.stream().map(MaProject::getProjectId).collect(Collectors.toList());
|
|
|
|
|
+ LambdaQueryWrapper<Project> query1 = new LambdaQueryWrapper<>();
|
|
|
|
|
+ query1.eq(Project::getType, typeId);
|
|
|
|
|
+ query1.notIn(Project::getId, projectIdList);
|
|
|
|
|
+ return projectMapper.selectList(query1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 申请开通新服务
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param dto
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public int applyForService(MaProjectSaveDto dto) {
|
|
|
|
|
+ if (Objects.isNull(dto)) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dto.getProjectIdList().size() > 0) {
|
|
|
|
|
+ // 插入商户技能
|
|
|
|
|
+ extracted(dto);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void extracted(MaProjectSaveDto dto) {
|
|
|
|
|
+ LambdaQueryWrapper<Project> query = new LambdaQueryWrapper<>();
|
|
|
|
|
+ query.in(Project::getId, dto.getProjectIdList());
|
|
|
|
|
+ List<Project> projectList = projectMapper.selectList(query);
|
|
|
|
|
+ for (Project project : projectList) {
|
|
|
|
|
+ MaProject maProject = new MaProject();
|
|
|
|
|
+ maProject.setProjectId(project.getId().toString());
|
|
|
|
|
+ maProject.setProjectName(project.getTitle());
|
|
|
|
|
+ maProject.setProjectDescribe(project.getDetail());
|
|
|
|
|
+ maProject.setProjectDuration(project.getStandardDuration());
|
|
|
|
|
+ maProject.setProjectOriginalPrice(project.getPrice());
|
|
|
|
|
+ maProject.setProjectMaxPrice(project.getPriceMax());
|
|
|
|
|
+ maProject.setProjectLowestPrice(project.getPriceMin());
|
|
|
|
|
+ maProject.setCreateBy(dto.getUserId());
|
|
|
|
|
+ maProject.setMerchantId(dto.getUserId());
|
|
|
|
|
+ maProject.setApplyTime((Data) new Date());
|
|
|
|
|
+ maProject.setMerchantPhone(dto.getMerchantPhone());
|
|
|
|
|
+ maProjectMapper.insert(maProject);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|