Merge remote-tracking branch 'xfsg/cc_partner_init' into cc_partner_init

This commit is contained in:
苏竹红
2024-04-07 17:07:49 +08:00
7 changed files with 72 additions and 6 deletions

View File

@@ -66,5 +66,4 @@ public interface EnterpriseUserMapper {
EnterpriseUserDO selectByMobile( @Param("mobile") String mobile);
EnterpriseUserDO selectByInvestmentManager( @Param("investmentManager") String investmentManager);
}

View File

@@ -97,4 +97,5 @@ public interface RegionMapper {
List<RegionDO> listByThirdRegionType(@Param("parentId")Long parentId, @Param("thirdRegionType")String thirdRegionType);
RegionDO getRegionByStoreId(@Param("storeId") String storeId);
}

View File

@@ -138,4 +138,5 @@ public interface SysRoleMapper {
List<SysRoleDO> getRolesByNamesAndSource(@Param("roleNames") List<String> roleNames, @Param("source") String source);
List<SysRoleDO> getXFStoreManager(@Param("roleNames") List<String> roleNames);
}

View File

@@ -345,6 +345,13 @@
and third_region_type = #{thirdRegionType}
</if>
</select>
<select id="getRegionByStoreId" resultType="com.cool.store.entity.RegionDO">
select <include refid="fields"/>
from region_${enterpriseId}
where deleted = 0
and store_id = #{storeId}
and region_type = 'store'
</select>
</mapper>

View File

@@ -358,5 +358,21 @@
#{roleName}
</foreach>
</select>
<select id="getXFStoreManager" resultType="com.cool.store.entity.SysRoleDO">
select
*
from sys_role_${enterpriseId}
where
(
source = 'sync'
or
source = 'sync_position'
)
and role_name in
<foreach collection="roleNames" item="roleName" open="(" close=")" separator=",">
#{roleName}
</foreach>
</select>
</mapper>

View File

@@ -31,5 +31,7 @@ public class LeaseBaseInfoDO {
private Integer deleted;
private String storeManager;
}

View File

@@ -1,16 +1,14 @@
package com.cool.store.service.impl;
import com.cool.store.dao.LineInfoDAO;
import com.cool.store.entity.LeaseBaseInfoDO;
import com.cool.store.entity.LineInfoDO;
import com.cool.store.entity.*;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.ExperienceStatusEnum;
import com.cool.store.enums.WorkflowSubStageEnum;
import com.cool.store.enums.WorkflowSubStageStatusEnum;
import com.cool.store.enums.*;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.LineInfoMapper;
import com.cool.store.mapper.TrainingExperienceMapper;
import com.cool.store.mapper.*;
import com.cool.store.request.TrainingExperienceDistributionRequest;
import com.cool.store.service.TrainingExperienceService;
import lombok.extern.slf4j.Slf4j;
@@ -19,7 +17,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.annotation.Tainted;
import java.util.Objects;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import static com.cool.store.enums.ErrorCodeEnum.INTERVIEW_LINE_ID_IS_NULL;
@@ -35,6 +35,22 @@ public class TrainingExperienceServiceImpl extends LineFlowService implements Tr
@Resource
LineInfoDAO lineInfoDAO;
@Resource
SysRoleMapper sysRoleMapper;
@Resource
EnterpriseUserMapper enterpriseUserMapper;
@Resource
RegionMapper regionMapper;
@Resource
UserAuthMappingMapper userAuthMappingMapper;
@Resource
EnterpriseUserRoleMapper enterpriseUserRoleMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean distribution(TrainingExperienceDistributionRequest request) {
@@ -45,6 +61,17 @@ public class TrainingExperienceServiceImpl extends LineFlowService implements Tr
throw new ServiceException(INTERVIEW_LINE_ID_IS_NULL);
}
LeaseBaseInfoDO leaseBaseInfoDO = request.toLeaseBaseInfoDO();
Date currentDate = new Date();
if (request.getExperienceStartTime().compareTo(request.getExperienceEndTime()) >= 0){
throw new ServiceException("结束时间不能早于开始时间");
}
if (currentDate.before(request.getExperienceStartTime())){
leaseBaseInfoDO.setExperienceStatus(WorkflowSubStageStatusEnum.STORE_EXPERIENCE_85.getCode());
}else if (currentDate.after(request.getExperienceStartTime()) || currentDate.before(request.getExperienceEndTime())){
leaseBaseInfoDO.setExperienceStatus(WorkflowSubStageStatusEnum.STORE_EXPERIENCE_90.getCode());
}else {
throw new ServiceException("时间");
}
trainingExperienceMapper.insert(leaseBaseInfoDO);
LineInfoDO lineInfoDO = new LineInfoDO();
lineInfoDO.setWorkflowSubStage(WorkflowSubStageEnum.STORE_EXPERIENCE.getCode());
@@ -71,7 +98,20 @@ public class TrainingExperienceServiceImpl extends LineFlowService implements Tr
@Override
public LeaseBaseInfoDO getTrainingExperience(Long lineId) {
String eid = "e17cd2dc350541df8a8b0af9bd27f77d";
List<String> roleNames = new ArrayList<>();
roleNames.add("加盟店店长");
roleNames.add("加盟店储备店长");
LeaseBaseInfoDO leaseBaseInfoDO = trainingExperienceMapper.selectByLineId(lineId);
String storeId = leaseBaseInfoDO.getStoreId();
RegionDO regionDO = regionMapper.getRegionByStoreId(storeId);
List<SysRoleDO> xfStoreManager = sysRoleMapper.getXFStoreManager(roleNames);
List<Long> roleIds = xfStoreManager.stream().map(SysRoleDO::getId).collect(Collectors.toList());
List<String> userIdsByRoleIdList = enterpriseUserRoleMapper.getUserIdsByRoleIdList(roleIds);
List<EnterpriseUserDO> userInfoByUserIds = enterpriseUserMapper.getUserInfoByUserIds(userIdsByRoleIdList);
String storeManagers = userInfoByUserIds.stream().map(EnterpriseUserDO::getName).collect(Collectors.toList()).toString();
leaseBaseInfoDO.setStoreManager(storeManagers);
return leaseBaseInfoDO;
}