|
@@ -1,29 +1,19 @@
|
|
|
package com.ylx.massage.service.impl;
|
|
package com.ylx.massage.service.impl;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.LinkedHashSet;
|
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
|
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.ylx.common.core.domain.model.LoginUser;
|
|
|
|
|
-import com.ylx.common.exception.ServiceException;
|
|
|
|
|
-import com.ylx.common.utils.DateUtils;
|
|
|
|
|
-import com.ylx.common.utils.StringUtils;
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ylx.massage.domain.MaProject;
|
|
import com.ylx.massage.domain.MaProject;
|
|
|
-import com.ylx.massage.domain.MaTeProject;
|
|
|
|
|
-import com.ylx.massage.domain.dto.MaTechnicianMerchantAddDTO;
|
|
|
|
|
-import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
|
|
|
|
|
-import com.ylx.massage.domain.dto.MassageMerchantRecommendDto;
|
|
|
|
|
|
|
+import com.ylx.massage.domain.dto.MaProjectSaveDto;
|
|
|
import com.ylx.massage.domain.vo.MaTechnicianAppAddVo;
|
|
import com.ylx.massage.domain.vo.MaTechnicianAppAddVo;
|
|
|
-import com.ylx.massage.domain.vo.MaTechnicianMerchantListVO;
|
|
|
|
|
-import com.ylx.massage.domain.vo.MerchantVo;
|
|
|
|
|
import com.ylx.massage.mapper.MaProjectMapper;
|
|
import com.ylx.massage.mapper.MaProjectMapper;
|
|
|
-import com.ylx.massage.mapper.MaTeProjectMapper;
|
|
|
|
|
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;
|
|
@@ -39,27 +29,81 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
* @date 2024-03-22
|
|
* @date 2024-03-22
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
-public class MaTechnicianServiceImpl implements IMaTechnicianService
|
|
|
|
|
-{
|
|
|
|
|
- private static final int SERVICE_STATE_AVAILABLE = 1;
|
|
|
|
|
- private static final int POST_STATE_OFFLINE = 0;
|
|
|
|
|
- private static final int ENABLED = 1;
|
|
|
|
|
- private static final int DEFAULT_AGE = 18;
|
|
|
|
|
- private static final int AUDIT_APPROVED = 2;
|
|
|
|
|
- private static final int NS_STATUS_NOT_ON_DUTY = -1;
|
|
|
|
|
- private static final int DEFAULT_STAT_VALUE = 0;
|
|
|
|
|
- private static final long NOT_DELETED = 0L;
|
|
|
|
|
- private static final String MERCHANT_STATUS_NORMAL = "0";
|
|
|
|
|
-
|
|
|
|
|
|
|
+public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaTechnician> implements IMaTechnicianService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MaTechnicianMapper maTechnicianMapper;
|
|
private MaTechnicianMapper maTechnicianMapper;
|
|
|
-
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private MaTeProjectMapper maTeProjectMapper;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ private MaProjectMapper maProjectMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ProjectMapper projectMapper;
|
|
private ProjectMapper projectMapper;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 商户入驻申请注册
|
|
|
|
|
+ *
|
|
|
|
|
+ * @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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询技师
|
|
* 查询技师
|
|
|
*
|
|
*
|
|
@@ -67,8 +111,7 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
|
|
|
* @return 技师
|
|
* @return 技师
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public MaTechnician selectMaTechnicianById(Long id)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public MaTechnician selectMaTechnicianById(Long id) {
|
|
|
return maTechnicianMapper.selectMaTechnicianById(id);
|
|
return maTechnicianMapper.selectMaTechnicianById(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -79,8 +122,7 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
|
|
|
* @return 技师
|
|
* @return 技师
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public List<MaTechnician> selectMaTechnicianList(MaTechnician maTechnician)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public List<MaTechnician> selectMaTechnicianList(MaTechnician maTechnician) {
|
|
|
return maTechnicianMapper.selectMaTechnicianList(maTechnician);
|
|
return maTechnicianMapper.selectMaTechnicianList(maTechnician);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -92,100 +134,39 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public int insertMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo)
|
|
|
|
|
- {
|
|
|
|
|
- MaTechnician maTechnician = new MaTechnician();
|
|
|
|
|
- BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);
|
|
|
|
|
- int rows = maTechnicianMapper.insertMaTechnician(maTechnician);
|
|
|
|
|
- if (maTechnicianAppAddVo.getProjectIds() != null && !maTechnicianAppAddVo.getProjectIds().isEmpty()) {
|
|
|
|
|
- insertProjectRelations(maTechnician.getId(), new LinkedHashSet<>(maTechnicianAppAddVo.getProjectIds()));
|
|
|
|
|
- }
|
|
|
|
|
- return rows;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 后台新增商户
|
|
|
|
|
- *
|
|
|
|
|
- * @param dto 新增商户参数
|
|
|
|
|
- * @param loginUser 当前登录用户
|
|
|
|
|
- * @return 结果
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
- public int insertMerchant(MaTechnicianMerchantAddDTO dto, LoginUser loginUser) {
|
|
|
|
|
- Set<Long> projectIds = checkMerchantAddParam(dto);
|
|
|
|
|
- String userName = loginUser.getUser().getUserName();
|
|
|
|
|
|
|
+ public int insertMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo) {
|
|
|
|
|
|
|
|
MaTechnician maTechnician = new MaTechnician();
|
|
MaTechnician maTechnician = new MaTechnician();
|
|
|
- maTechnician.setTeName(dto.getTeName().trim());
|
|
|
|
|
- maTechnician.setTeNickName(dto.getTeNickName().trim());
|
|
|
|
|
- maTechnician.setTeSex(dto.getTeSex());
|
|
|
|
|
- maTechnician.setTePhone(dto.getTePhone().trim());
|
|
|
|
|
- maTechnician.setOpenService(dto.getOpenService());
|
|
|
|
|
- dto.getProjectIds().forEach(projectId -> {
|
|
|
|
|
- Project project = projectMapper.selectById(projectId);
|
|
|
|
|
- if (project != null) {
|
|
|
|
|
- maTechnician.setTeProject(project.getTitle() + ",");
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- //移除末尾的逗号
|
|
|
|
|
- maTechnician.setTeProject(StrUtil.removeSuffix(maTechnician.getTeProject(), ","));
|
|
|
|
|
-
|
|
|
|
|
- maTechnician.setTechType(dto.getTechType());
|
|
|
|
|
- maTechnician.setIsRecommend(normalizeSwitchValue(dto.getIsRecommend(), "是否推荐"));
|
|
|
|
|
-
|
|
|
|
|
- maTechnician.setServiceState(SERVICE_STATE_AVAILABLE);
|
|
|
|
|
- maTechnician.setPostState(POST_STATE_OFFLINE);
|
|
|
|
|
- maTechnician.setTeIsEnable(ENABLED);
|
|
|
|
|
- //上岗状态:默认-1 未上岗
|
|
|
|
|
- maTechnician.setNStatus2(NS_STATUS_NOT_ON_DUTY);
|
|
|
|
|
- maTechnician.setMerchantStatus(MERCHANT_STATUS_NORMAL);
|
|
|
|
|
- //审核状态
|
|
|
|
|
- maTechnician.setAuditStatus(AUDIT_APPROVED);
|
|
|
|
|
- maTechnician.setTeAddress("");
|
|
|
|
|
- maTechnician.setNStar(DEFAULT_STAT_VALUE);
|
|
|
|
|
- maTechnician.setNNum(DEFAULT_STAT_VALUE);
|
|
|
|
|
- maTechnician.setCreateBy(userName);
|
|
|
|
|
- maTechnician.setUpdateBy(userName);
|
|
|
|
|
- maTechnician.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
- maTechnician.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
-
|
|
|
|
|
- int rows = maTechnicianMapper.insert(maTechnician);
|
|
|
|
|
- if (rows <= 0) {
|
|
|
|
|
- throw new ServiceException("新增商户失败");
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);
|
|
|
|
|
+ int i = maTechnicianMapper.insert(maTechnician);
|
|
|
|
|
+ // maTechnicianMapper.insertMaTechnician(maTechnician);
|
|
|
|
|
+ if (!maTechnicianAppAddVo.getProjectIds().isEmpty()) {
|
|
|
|
|
+// ArrayList<MaTeProject> objects = Lists.newArrayList();
|
|
|
|
|
+// ArrayList<Long> projectIds = maTechnicianAppAddVo.getProjectIds();
|
|
|
|
|
+// projectIds.forEach(id->{
|
|
|
|
|
+// MaTeProject maTeProject = new MaTeProject();
|
|
|
|
|
+// maTeProject.setTeId(maTechnician.getId());
|
|
|
|
|
+// maTeProject.setProjectId(id);
|
|
|
|
|
+// objects.add(maTeProject);
|
|
|
|
|
+// });
|
|
|
|
|
+// i = maTeProjectMapper.insertBatch(objects);
|
|
|
}
|
|
}
|
|
|
- insertProjectRelations(maTechnician.getId(), projectIds);
|
|
|
|
|
- return rows;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 后台查询商户列表
|
|
|
|
|
- *
|
|
|
|
|
- * @param page 分页参数
|
|
|
|
|
- * @param dto 查询条件
|
|
|
|
|
- * @return 商户分页列表
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public Page<MaTechnicianMerchantListVO> selectMerchantList(Page<MaTechnicianMerchantListVO> page,
|
|
|
|
|
- MaTechnicianMerchantQueryDTO dto) {
|
|
|
|
|
- Page<MaTechnicianMerchantListVO> pageParam = page == null ? new Page<>(1, 10) : page;
|
|
|
|
|
- return maTechnicianMapper.selectMerchantList(pageParam, dto);
|
|
|
|
|
|
|
+ return i;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 修改技师
|
|
* 修改技师
|
|
|
*
|
|
*
|
|
|
- * @param maTechnicianAppAddVo
|
|
|
|
|
|
|
+ * @param maTechnicianAppAddVo
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int updateMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int updateMaTechnician(MaTechnicianAppAddVo maTechnicianAppAddVo) {
|
|
|
|
|
|
|
|
MaTechnician maTechnician = new MaTechnician();
|
|
MaTechnician maTechnician = new MaTechnician();
|
|
|
BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);
|
|
BeanUtils.copyProperties(maTechnicianAppAddVo, maTechnician);
|
|
|
|
|
|
|
|
- return maTechnicianMapper.updateMaTechnician(maTechnician);
|
|
|
|
|
|
|
+ return maTechnicianMapper.updateById(maTechnician);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -195,8 +176,7 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int deleteMaTechnicianByIds(Long[] ids)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int deleteMaTechnicianByIds(Long[] ids) {
|
|
|
return maTechnicianMapper.deleteMaTechnicianByIds(ids);
|
|
return maTechnicianMapper.deleteMaTechnicianByIds(ids);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -207,134 +187,101 @@ public class MaTechnicianServiceImpl implements IMaTechnicianService
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int deleteMaTechnicianById(Long id)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int deleteMaTechnicianById(Long id) {
|
|
|
return maTechnicianMapper.deleteMaTechnicianById(id);
|
|
return maTechnicianMapper.deleteMaTechnicianById(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 首页选中的城市是否有开通服务
|
|
|
|
|
- * @param areaCode
|
|
|
|
|
|
|
+ * 查询商户技能
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public Boolean isHasMerchantCity(String areaCode) {
|
|
|
|
|
- LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- queryWrapper.eq(MaTechnician::getTeAreaCode, areaCode);
|
|
|
|
|
- return maTechnicianMapper.selectCount(queryWrapper) > 0;
|
|
|
|
|
|
|
+ public List<MaProject> selectMaTechnicianListBy(String userId, String type) {
|
|
|
|
|
+ LambdaQueryWrapper<MaProject> query = new LambdaQueryWrapper<>();
|
|
|
|
|
+ query.eq(MaProject::getUserId, userId);
|
|
|
|
|
+ query.eq(MaProject::getAuditStatus, type);
|
|
|
|
|
+ return maProjectMapper.selectList(query);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 首页按摩推荐
|
|
|
|
|
- * @param dto
|
|
|
|
|
|
|
+ * 查询技能
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param typeId
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public List<MerchantVo> getMerchantRecommend(MassageMerchantRecommendDto dto) {
|
|
|
|
|
- return maTechnicianMapper.getMerchantRecommend(dto);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public List<Project> selectTechnicianListBy(String typeId) {
|
|
|
|
|
+ LambdaQueryWrapper<Project> query = new LambdaQueryWrapper<>();
|
|
|
|
|
+ query.eq(Project::getType, typeId);
|
|
|
|
|
+ query.eq(Project::getStatus, 0);
|
|
|
|
|
+ List<Project> projectList = projectMapper.selectList(query);
|
|
|
|
|
+ return projectList;
|
|
|
|
|
|
|
|
- private Set<Long> checkMerchantAddParam(MaTechnicianMerchantAddDTO dto) {
|
|
|
|
|
- if (dto == null) {
|
|
|
|
|
- throw new ServiceException("商户参数不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- checkRequiredText(dto.getTeName(), "姓名", 10);
|
|
|
|
|
- checkRequiredText(dto.getTeNickName(), "昵称", 10);
|
|
|
|
|
- checkRequiredText(dto.getTePhone(), "电话", 11);
|
|
|
|
|
- checkEnumValue(dto.getTeSex(), "性别", 0, 1);
|
|
|
|
|
- //checkEnumValue(dto.getOpenService(), "服务类目", 1, 2);
|
|
|
|
|
- //校验服务类名不能为空
|
|
|
|
|
- if (dto.getOpenService() == null) {
|
|
|
|
|
- throw new ServiceException("服务类目不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- checkEnumValue(dto.getTechType(), "商户类型", 0, 1);
|
|
|
|
|
- if (dto.getIsRecommend() != null) {
|
|
|
|
|
- checkEnumValue(dto.getIsRecommend(), "是否推荐", 0, 1);
|
|
|
|
|
- }
|
|
|
|
|
- return checkProjectIds(dto.getProjectIds());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void checkRequiredText(String value, String fieldName, int maxLength) {
|
|
|
|
|
- if (StringUtils.isBlank(value)) {
|
|
|
|
|
- throw new ServiceException(fieldName + "不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- if (value.trim().length() > maxLength) {
|
|
|
|
|
- throw new ServiceException(fieldName + "长度不能超过" + maxLength + "个字符");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void checkEnumValue(Integer value, String fieldName, int... allowedValues) {
|
|
|
|
|
- if (value == null) {
|
|
|
|
|
- throw new ServiceException(fieldName + "不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- for (int allowedValue : allowedValues) {
|
|
|
|
|
- if (value == allowedValue) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- throw new ServiceException(fieldName + "值不正确");
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private Integer normalizeSwitchValue(Integer value, String fieldName) {
|
|
|
|
|
- if (value == null) {
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
- checkEnumValue(value, fieldName, 0, 1);
|
|
|
|
|
- return value;
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取未申请技能列表
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param typeId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<Project> getNotApplyList(String userId, String typeId){
|
|
|
|
|
+ LambdaQueryWrapper<MaProject> query = new LambdaQueryWrapper<>();
|
|
|
|
|
+ query.eq(MaProject::getUserId, 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);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 校验服务项目ID集合
|
|
|
|
|
- * @param projectIds
|
|
|
|
|
- * @return 有效服务项目ID集合
|
|
|
|
|
|
|
+ * 申请开通服务
|
|
|
|
|
+ * @param dto
|
|
|
|
|
+ * @return
|
|
|
*/
|
|
*/
|
|
|
- private Set<Long> checkProjectIds(List<Long> projectIds) {
|
|
|
|
|
- if (projectIds == null || projectIds.isEmpty()) {
|
|
|
|
|
- throw new ServiceException("服务项目不能为空");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Set<Long> distinctProjectIds = new LinkedHashSet<>();
|
|
|
|
|
- for (Long projectId : projectIds) {
|
|
|
|
|
- if (projectId == null) {
|
|
|
|
|
- throw new ServiceException("服务项目ID不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- distinctProjectIds.add(projectId);
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public int applyForService(MaProjectSaveDto dto) {
|
|
|
|
|
+ if (Objects.isNull(dto)) {
|
|
|
|
|
+ return 0;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /*int validCount = 0;
|
|
|
|
|
- for (Long projectId : distinctProjectIds) {
|
|
|
|
|
- MaProject project = maProjectMapper.selectMaProjectById(projectId);
|
|
|
|
|
- if (project != null && (project.getIsDelete() == null || project.getIsDelete() != 1)) {
|
|
|
|
|
- validCount++;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (dto.getProjectIdList().size() > 0) {
|
|
|
|
|
+ // 插入商户技能
|
|
|
|
|
+ extracted(dto);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return 0;
|
|
|
}
|
|
}
|
|
|
- if (validCount != distinctProjectIds.size()) {
|
|
|
|
|
- throw new ServiceException("服务项目不存在或已删除");
|
|
|
|
|
- }*/
|
|
|
|
|
- return distinctProjectIds;
|
|
|
|
|
|
|
+ return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 新增商户与服务项目关联关系
|
|
|
|
|
- *
|
|
|
|
|
- * @param technicianId
|
|
|
|
|
- * @param projectIds
|
|
|
|
|
|
|
+ * 插入商户技能
|
|
|
|
|
+ * @param dto
|
|
|
*/
|
|
*/
|
|
|
- private void insertProjectRelations(Long technicianId, Set<Long> projectIds) {
|
|
|
|
|
- if (technicianId == null) {
|
|
|
|
|
- throw new ServiceException("商户ID不能为空");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- List<MaTeProject> relations = new ArrayList<>();
|
|
|
|
|
- for (Long projectId : projectIds) {
|
|
|
|
|
- MaTeProject relation = new MaTeProject();
|
|
|
|
|
- relation.setTeId(technicianId);
|
|
|
|
|
- relation.setProjectId(projectId);
|
|
|
|
|
- relations.add(relation);
|
|
|
|
|
- }
|
|
|
|
|
- int rows = maTeProjectMapper.insertBatch(relations);
|
|
|
|
|
- if (rows != relations.size()) {
|
|
|
|
|
- throw new ServiceException("新增商户服务项目失败");
|
|
|
|
|
|
|
+ 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.setUserId(dto.getUserId());
|
|
|
|
|
+ maProject.setApplyTime((Data) new Date());
|
|
|
|
|
+ maProject.setMerchantPhone(dto.getMerchantPhone());
|
|
|
|
|
+ maProjectMapper.insert(maProject);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|