Quellcode durchsuchen

广誉源商户端-登录-我的技能

jinwenhai vor 6 Tagen
Ursprung
Commit
08ef79c2b4

+ 2 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/mapper/MaProjectMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ylx.massage.domain.MaProject;
 import com.ylx.massage.domain.vo.MassageProjectRecommendVo;
+import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 /**
@@ -14,6 +15,7 @@ import org.apache.ibatis.annotations.Param;
  * @author ylx
  * @date 2024-03-20
  */
+@Mapper
 public interface MaProjectMapper extends BaseMapper<MaProject> {
     /**
      * 查询服务项目

+ 18 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/mapper/MaTechnicianMapper.java

@@ -3,7 +3,14 @@ package com.ylx.massage.mapper;
 import java.util.List;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ylx.massage.domain.MaTechnician;
+import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
+import com.ylx.massage.domain.dto.MassageMerchantRecommendDto;
+import com.ylx.massage.domain.vo.MaTechnicianMerchantListVO;
+import com.ylx.massage.domain.vo.MassageProjectRecommendVo;
+import com.ylx.massage.domain.vo.MerchantVo;
+import org.apache.ibatis.annotations.Param;
 import org.mapstruct.Mapper;
 
 /**
@@ -62,4 +69,15 @@ public interface MaTechnicianMapper extends BaseMapper<MaTechnician>
      * @return 结果
      */
     public int deleteMaTechnicianByIds(Long[] ids);
+    /**
+     * 后台查询商户列表
+     *
+     * @param page 分页参数
+     * @param dto 查询条件
+     * @return 商户分页列表
+     */
+    Page<MaTechnicianMerchantListVO> selectMerchantList(Page<MaTechnicianMerchantListVO> page,
+                                                        @Param("dto") MaTechnicianMerchantQueryDTO dto);
+
+    List<MerchantVo> getMerchantRecommend(@Param("dto") MassageMerchantRecommendDto dto);
 }

+ 36 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/service/IMaTechnicianService.java

@@ -2,12 +2,20 @@ package com.ylx.massage.service;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ylx.common.core.domain.model.LoginUser;
 import com.ylx.massage.domain.MaProject;
 import com.ylx.massage.domain.MaTechnician;
 import com.ylx.massage.domain.dto.MaProjectSaveDto;
+import com.ylx.massage.domain.dto.MaTechnicianMerchantAddDTO;
+import com.ylx.massage.domain.dto.MaTechnicianMerchantQueryDTO;
 import com.ylx.massage.domain.vo.MaTechnicianAppAddVo;
+import com.ylx.massage.domain.vo.MaTechnicianMerchantListVO;
+import com.ylx.massage.domain.vo.MerchantVo;
 import com.ylx.project.domain.Project;
+import com.ylx.massage.domain.dto.MassageMerchantRecommendDto;
+
 
 /**
  * 技师Service接口
@@ -103,4 +111,32 @@ public interface IMaTechnicianService extends IService<MaTechnician> {
      * @return
      */
     int applyForService(MaProjectSaveDto dto);
+    /**
+     * 首页选中的城市是否有开通服务
+     * @param areaCode
+     * @return
+     */
+    public  Boolean isHasMerchantCity(String areaCode);
+
+    public List<MerchantVo> getMerchantRecommend(MassageMerchantRecommendDto dto);
+
+    /**
+     * 后台新增商户
+     *
+     * @param dto 新增商户参数
+     * @param loginUser 当前登录用户
+     * @return 结果
+     */
+    public int insertMerchant(MaTechnicianMerchantAddDTO dto, LoginUser loginUser);
+
+    /**
+     * 后台查询商户列表
+     *
+     * @param page 分页参数
+     * @param dto 查询条件
+     * @return 商户分页列表
+     */
+    public Page<MaTechnicianMerchantListVO> selectMerchantList(Page<MaTechnicianMerchantListVO> page,
+                                                               MaTechnicianMerchantQueryDTO dto);
+
 }

+ 6 - 2
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/MaProjectServiceImpl.java

@@ -4,13 +4,17 @@ import java.util.ArrayList;
 import java.util.List;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ylx.common.core.domain.model.LoginUser;
 import com.ylx.common.utils.DateUtils;
 import com.ylx.common.utils.bean.BeanUtils;
+import com.ylx.massage.domain.MaTechnician;
 import com.ylx.massage.domain.vo.MaProjectListVo;
 import com.ylx.massage.domain.vo.MaProjectSaveVo;
 import com.ylx.massage.domain.vo.MassageProjectRecommendVo;
 import com.ylx.massage.mapper.MaProjectMapper;
+import com.ylx.massage.mapper.MaTechnicianMapper;
+import com.ylx.massage.service.IMaTechnicianService;
 import org.apache.commons.compress.utils.Lists;
 import org.springframework.stereotype.Service;
 import com.ylx.massage.domain.MaProject;
@@ -25,7 +29,7 @@ import javax.annotation.Resource;
  * @date 2024-03-20
  */
 @Service
-public class MaProjectServiceImpl implements IMaProjectService
+public class MaProjectServiceImpl extends ServiceImpl<MaProjectMapper, MaProject> implements IMaProjectService
 {
     @Resource
     private MaProjectMapper maProjectMapper;
@@ -72,7 +76,7 @@ public class MaProjectServiceImpl implements IMaProjectService
     /**
      * 新增服务项目
      *
-     * @param maProject 服务项目
+     * @param
      * @return 结果
      */
     @Override

+ 218 - 4
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/MaTechnicianServiceImpl.java

@@ -1,16 +1,27 @@
 package com.ylx.massage.service.impl;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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.ylx.massage.domain.MaProject;
+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.MaTechnicianMerchantQueryDTO;
+import com.ylx.massage.domain.dto.MassageMerchantRecommendDto;
 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.MaTeProjectMapper;
 import com.ylx.project.domain.Project;
 import com.ylx.project.mapper.ProjectMapper;
 import lombok.Data;
@@ -22,6 +33,8 @@ import com.ylx.massage.domain.MaTechnician;
 import com.ylx.massage.service.IMaTechnicianService;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
+
 /**
  * 技师Service业务层处理
  *
@@ -36,7 +49,17 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
     private MaProjectMapper maProjectMapper;
     @Autowired
     private ProjectMapper projectMapper;
-
+    @Resource
+    private MaTeProjectMapper maTeProjectMapper;
+    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";
     /**
      * 商户入驻申请注册
      *
@@ -55,7 +78,74 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
         maTechnicianMapper.insert(maTechnician);
 
     }
+    /**
+     * 后台新增商户
+     *
+     * @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();
 
+        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("新增商户失败");
+        }
+        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);
+    }
     /**
      * 商户入住前置条件校验
      *
@@ -284,4 +374,128 @@ public class MaTechnicianServiceImpl extends ServiceImpl<MaTechnicianMapper, MaT
             maProjectMapper.insert(maProject);
         }
     }
+    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;
+    }
+
+    /**
+     * 校验服务项目ID集合
+     * @param projectIds
+     * @return 有效服务项目ID集合
+     */
+    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);
+        }
+
+        /*int validCount = 0;
+        for (Long projectId : distinctProjectIds) {
+            MaProject project = maProjectMapper.selectMaProjectById(projectId);
+            if (project != null && (project.getIsDelete() == null || project.getIsDelete() != 1)) {
+                validCount++;
+            }
+        }
+        if (validCount != distinctProjectIds.size()) {
+            throw new ServiceException("服务项目不存在或已删除");
+        }*/
+        return distinctProjectIds;
+    }
+
+    /**
+     * 新增商户与服务项目关联关系
+     *
+     * @param technicianId
+     * @param projectIds
+     */
+    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("新增商户服务项目失败");
+        }
+    }
+    /**
+     * 首页选中的城市是否有开通服务
+     * @param areaCode
+     * @return
+     */
+    @Override
+    public Boolean isHasMerchantCity(String areaCode) {
+        LambdaQueryWrapper<MaTechnician> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(MaTechnician::getTeAreaCode, areaCode);
+        return maTechnicianMapper.selectCount(queryWrapper) > 0;
+    }
+
+    /**
+     * 首页按摩推荐
+     * @param dto
+     * @return
+     */
+    @Override
+    public List<MerchantVo> getMerchantRecommend(MassageMerchantRecommendDto dto) {
+        return maTechnicianMapper.getMerchantRecommend(dto);
+    }
 }

+ 5 - 5
nightFragrance-massage/src/main/java/com/ylx/userhome/area/controller/CustomerCityController.java

@@ -47,11 +47,11 @@ public class CustomerCityController {
         }
     }
 
-    @ApiOperation(value="首页选中的城市是否有开通服务", notes="首页选中的城市是否有开通服务;true表示该城市有开通服务")
-    @GetMapping(value = "/isHasMerchantCity")
-    public R<Boolean> isHasMerchantCity(@RequestParam("areaCode") String areaCode) {
-            return R.ok(iMaTechnicianService.isHasMerchantCity(areaCode));
-    }
+//    @ApiOperation(value="首页选中的城市是否有开通服务", notes="首页选中的城市是否有开通服务;true表示该城市有开通服务")
+//    @GetMapping(value = "/isHasMerchantCity")
+//    public R<Boolean> isHasMerchantCity(@RequestParam("areaCode") String areaCode) {
+//            return R.ok(iMaTechnicianService.isHasMerchantCity(areaCode));
+//    }
 
     /**
      * 首页-城市列表查询

+ 2 - 0
nightFragrance-massage/src/main/resources/mapper/massage/MaTechnicianMapper.xml

@@ -344,4 +344,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY t.n_num DESC
         LIMIT 5
     </select>
+
+
 </mapper>