Merge remote-tracking branch 'origin/dev/feat/partner1.6_20231226' into dev/feat/partner1.6_20231226

This commit is contained in:
feng.li
2023-12-12 18:54:21 +08:00
18 changed files with 436 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import com.cool.store.context.LoginUserInfo;
import com.cool.store.dto.exhibition.ExhibitionDTO;
import com.cool.store.dto.exhibition.ExhibitionEnterInterviewDTO;
import com.cool.store.dto.exhibition.ExhibitionGroupDTO;
import com.cool.store.dto.exhibition.SignUpExhibitionDTO;
import com.cool.store.exception.ApiException;
import com.cool.store.vo.EnterInterviewVO;
import com.cool.store.vo.exhibition.*;
@@ -101,4 +102,14 @@ public interface ExhibitionService {
List<ExhibitionLineBaseVO> exhibitionLineBaseList(Integer exhibitionId,String partnerName);
/**
* 报名会销
* @param signUpExhibitionDTO
* @param userInfo
* @return
*/
SignUpExhibitionVO signUpExhibition(SignUpExhibitionDTO signUpExhibitionDTO,LoginUserInfo userInfo) throws ApiException;
Boolean cancelSignUpExhibition(Integer exhibitionId,Long lineId,LoginUserInfo userInfo);
}

View File

@@ -10,6 +10,7 @@ import com.cool.store.context.LoginUserInfo;
import com.cool.store.dao.*;
import com.cool.store.dto.exhibition.*;
import com.cool.store.dto.partner.LineInterviewDTO;
import com.cool.store.dto.partner.MobileCheckDTO;
import com.cool.store.entity.*;
import com.cool.store.enums.*;
import com.cool.store.exception.ApiException;
@@ -23,6 +24,7 @@ import com.cool.store.service.InterviewService;
import com.cool.store.service.WechatMiniAppService;
import com.cool.store.utils.CoolDateUtils;
import com.cool.store.utils.TRTCUtils;
import com.cool.store.utils.UUIDUtils;
import com.cool.store.utils.poi.StringUtils;
import com.cool.store.utils.poi.constant.Constants;
import com.cool.store.vo.EnterInterviewVO;
@@ -33,6 +35,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,6 +43,7 @@ import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -78,6 +82,11 @@ public class ExhibitionServiceImpl implements ExhibitionService {
@Autowired
private TRTCUtils trtcUtils;
@Resource
HyPartnerUserInfoDAO hyPartnerUserInfoDAO;
// @Value("${offline.exhibition.channel.id}")
// private Integer offlineExhibition;
@Override
@Transactional
public EnterInterviewVO startExhibitionInterview(ExhibitionEnterInterviewDTO dto) throws ApiException {
@@ -487,6 +496,175 @@ public class ExhibitionServiceImpl implements ExhibitionService {
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public SignUpExhibitionVO signUpExhibition(SignUpExhibitionDTO signUpExhibitionDTO, LoginUserInfo userInfo) throws ApiException {
//报名会销
if (signUpExhibitionDTO.getExhibitionId() == null){
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
}
HyExhibitionDO hyExhibitionDO = hyExhibitionDAO.selectByPrimaryKey(signUpExhibitionDTO.getExhibitionId());
if (hyExhibitionDO == null){
throw new ServiceException(ErrorCodeEnum.EXHIBITION_NOT_EXIST);
}
//先判断会销是否结束 已结束不能报名
if(hyExhibitionDO.getClosedType()!=0){
return new SignUpExhibitionVO(Boolean.FALSE,CommonConstants.ONE,SignUpStatusEnum.getSignUpFailMsg(SignUpStatusEnum.Sign_UP_FAIL_1));
}
//是否存在线索
//查询线索信息
MobileCheckDTO mobileCheckDTO = hyPartnerUserInfoDAO.selectByCheckMobile(signUpExhibitionDTO.getMobile());
//线索不存在
Boolean sendNotice = Boolean.TRUE;
String investManager = mobileCheckDTO.getInvestmentManager();
String partnerId = mobileCheckDTO.getPartnerId();
Long lineId = mobileCheckDTO.getLineId();
if (mobileCheckDTO == null||mobileCheckDTO.getLineStatus() == null){
//走这里不需要发送通知
sendNotice = Boolean.FALSE;
//mobileCheckDTO为空 表示从没有授权过 mobileCheckDTO不为空 但是线索状态为空 表示授权过 但是没有线索
if (mobileCheckDTO==null){
partnerId = UUIDUtils.get32UUID();
HyPartnerUserInfoDO resultUser = new HyPartnerUserInfoDO();
resultUser.setUsername(signUpExhibitionDTO.getPartnerName()).setMobile(signUpExhibitionDTO.getMobile()).setPartnerId(partnerId).setCreateTime(new Date())
.setWantShopArea(signUpExhibitionDTO.getWantShopArea()).setUserChannelId(111111111);
hyPartnerUserInfoDAO.insertSelective(resultUser);
}
HyPartnerLineInfoDO resultLine = new HyPartnerLineInfoDO();
resultLine.setPartnerId(partnerId).setCreateTime(new Date()).setWorkflowStage(WorkflowStageEnum.INTENT.getCode())
.setCreateUserId(CurrentUserHolder.getUserId()).setCreateUserMobile(CurrentUserHolder.getUser().getMobile())
.setOperatorType("add").setAllotTime(new Date()).setLineStatus(LineStatusEnum.PRIVATE_SEAS.getCode()).setInvestmentManager(hyExhibitionDO.getCreator());
hyPartnerLineInfoDAO.insertSelective(resultLine);
lineId = resultLine.getId();
}
//如果是公海状态 但是结束时间不为空
if (LineStatusEnum.PUBLIC_SEAS.getCode().equals(mobileCheckDTO.getLineStatus())){
//不管冷静期有没有结束 会销创建人直接认领改线索
//发送工作通知的招商经理
investManager = hyExhibitionDO.getCreator();
if(mobileCheckDTO.getCloseTime()!=null){
//将老的线索置为删除状态
hyPartnerLineInfoDAO.batchDeleted(Arrays.asList(Long.valueOf(lineId)));
HyPartnerLineInfoDO hyPartnerLineInfoDO = new HyPartnerLineInfoDO();
hyPartnerLineInfoDO.setPartnerId(partnerId);
//给会销创建人
hyPartnerLineInfoDO.setInvestmentManager(hyExhibitionDO.getCreator());
hyPartnerLineInfoDO.setWorkflowStage(WorkflowStageEnum.INTENT.getCode());
hyPartnerLineInfoDO.setWorkflowStatus(WorkflowStatusEnum.INTENT_0.getCode());
hyPartnerLineInfoDO.setLineStatus(1);
hyPartnerLineInfoDO.setAllotTime(new Date());
hyPartnerLineInfoDAO.insertSelective(hyPartnerLineInfoDO);
lineId = hyPartnerLineInfoDO.getId();
}else{
//如果首次在私海 直接分配会销创建人为线索招商经理
HyPartnerLineInfoDO hyPartnerLineInfoDO = new HyPartnerLineInfoDO();
hyPartnerLineInfoDO.setId(Long.valueOf(lineId));
hyPartnerLineInfoDO.setAllotTime(new Date());
hyPartnerLineInfoDO.setLineStatus(LineStatusEnum.PRIVATE_SEAS.getCode());
hyPartnerLineInfoDO.setInvestmentManager(hyExhibitionDO.getCreator());
hyPartnerLineInfoDAO.updateByPrimaryKeySelective(hyPartnerLineInfoDO);
}
}
SignUpExhibitionVO signUpExhibitionVO = checkSignUp(mobileCheckDTO);
if (signUpExhibitionVO!=null){
return signUpExhibitionVO;
}
//是否重复报名
Integer exhibitionGroupId = hyExhibitionDO.getExhibitionGroupId();
Integer count = hyExhibitionDAO.lineSignUpCount(exhibitionGroupId, lineId);
if (count > 0){
HyExhibitionGroupDO hyExhibitionGroupDO = hyExhibitionGroupDAO.selectByPrimaryKey(exhibitionGroupId);
return new SignUpExhibitionVO(Boolean.FALSE,CommonConstants.THREE,SignUpStatusEnum.getSignUpFailMsg(SignUpStatusEnum.Sign_UP_FAIL_3,hyExhibitionGroupDO.getExhibitionGroupName()));
}
//开始报名
//判断是否之前报名过改会销
HyPartnerExhibitionDO partnerExhibition = hyPartnerExhibitionDAO.getPartnerExhibition(hyExhibitionDO.getId(), lineId);
if (partnerExhibition != null){
partnerExhibition.setParticipationStatus(ExhibitionPartnerStatus.REGISTERED.getCode());
partnerExhibition.setWantShopArea(signUpExhibitionDTO.getWantShopArea());
partnerExhibition.setInvestmentManagerName(signUpExhibitionDTO.getIntendedAccountManager());
partnerExhibition.setExpectedVisitorsCount(signUpExhibitionDTO.getExpectedVisitorsCount());
partnerExhibition.setExpectedInformation(signUpExhibitionDTO.getExpectedInformation());
hyPartnerExhibitionDAO.updateByPrimaryKeySelective(partnerExhibition);
}else {
HyPartnerExhibitionDO hyPartnerExhibitionDO = new HyPartnerExhibitionDO();
hyPartnerExhibitionDO.setExhibitionId(signUpExhibitionDTO.getExhibitionId());
hyPartnerExhibitionDO.setPartnerLineId(lineId);
hyPartnerExhibitionDO.setPartnerId(partnerId);
hyPartnerExhibitionDO.setWantShopArea(signUpExhibitionDTO.getWantShopArea());
hyPartnerExhibitionDO.setInvestmentManagerName(signUpExhibitionDTO.getIntendedAccountManager());
hyPartnerExhibitionDO.setExpectedVisitorsCount(signUpExhibitionDTO.getExpectedVisitorsCount());
hyPartnerExhibitionDO.setExpectedInformation(signUpExhibitionDTO.getExpectedInformation());
hyPartnerExhibitionDO.setParticipationStatus(ExhibitionPartnerStatus.REGISTERED.getCode());
hyPartnerExhibitionDO.setCreator(userInfo.getUserId());
hyPartnerExhibitionDAO.insertSelective(hyPartnerExhibitionDO);
}
//计算是否会销中
whetherInExhibition(lineId,Boolean.TRUE);
if (sendNotice){
//发送通知
eventCenterHttpRequest.sendFeiShuNotice(FeiShuNoticeMsgEnum.PARTNER_SIGNUP_EXHIBITION,Arrays.asList(investManager),mobileCheckDTO.getPartnerName(),mobileCheckDTO.getMobile(),
DateUtils.format(hyExhibitionDO.getStartDate(),CoolDateUtils.DATE_FORMAT_DAY_2),hyExhibitionDO.getExhibitionName(),hyExhibitionDO.getLocation());
}
return new SignUpExhibitionVO(Boolean.TRUE,CommonConstants.ZERO,null);
}
@Override
public Boolean cancelSignUpExhibition(Integer exhibitionId,Long lineId,LoginUserInfo userInfo) {
if (exhibitionId == null || lineId == null){
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
}
//取消报名
HyPartnerExhibitionDO partnerExhibition = hyPartnerExhibitionDAO.getPartnerExhibition(exhibitionId, lineId);
partnerExhibition.setParticipationStatus(ExhibitionPartnerStatus.SIGN_CANCELED.getCode());
partnerExhibition.setUpdater(userInfo.getUserId());
hyPartnerExhibitionDAO.updateByPrimaryKeySelective(partnerExhibition);
//计算是否会销中
whetherInExhibition(lineId,Boolean.FALSE);
return Boolean.TRUE;
}
/**
* 计算是否会销中
* @param lineId
*/
private void whetherInExhibition(Long lineId,Boolean insertFlag){
//计算是否会销中(报名了会销(不能是取消报名状态) 且会销属于开发中 )
Integer count = hyPartnerExhibitionDAO.partnerSignUpCount(lineId);
log.info("partnerSignUpCount:{}",count);
//会销状态
Boolean exhibitionStatus = (count>CommonConstants.ZERO||insertFlag)?Boolean.TRUE:Boolean.FALSE;
HyPartnerLineInfoDO hyPartnerLineInfoDO = new HyPartnerLineInfoDO();
hyPartnerLineInfoDO.setId(lineId);
hyPartnerLineInfoDO.setWhetherInExhibition(exhibitionStatus);
hyPartnerLineInfoDAO.updateByPrimaryKeySelective(hyPartnerLineInfoDO);
}
/**
* 校验报名
* @param mobileCheckDTO
* @return
*/
private SignUpExhibitionVO checkSignUp(MobileCheckDTO mobileCheckDTO){
//黑名单
if (LineStatusEnum.BLACKLIST.getCode().equals(mobileCheckDTO.getLineStatus())){
return new SignUpExhibitionVO(Boolean.FALSE,CommonConstants.TWO,SignUpStatusEnum.getSignUpFailMsg(SignUpStatusEnum.Sign_UP_FAIL_4));
}
//私海
//能报名的列表
Map<String,List<String>> map = WorkflowStageEnum.getExhibitionSignUpMap();
if (LineStatusEnum.PRIVATE_SEAS.getCode().equals(mobileCheckDTO.getLineStatus())){
List<String> list = map.get(mobileCheckDTO.getWorkflowStage());
if (!list.contains(mobileCheckDTO.getWorkflowStatus())){
HashMap<String, List<WorkflowStatusEnum>> workflowStatusMap = WorkflowStageEnum.getWorkflowStatusMap();
List<WorkflowStatusEnum> workflowStatusEnums = workflowStatusMap.get(mobileCheckDTO.getWorkflowStage());
Map<String, String> statusMap = workflowStatusEnums.stream().collect(Collectors.toMap(WorkflowStatusEnum::getCode, WorkflowStatusEnum::getMessage, (a, b) -> b));
return new SignUpExhibitionVO(Boolean.FALSE,CommonConstants.TWO,SignUpStatusEnum.getSignUpFailMsg(SignUpStatusEnum.Sign_UP_FAIL_2,
WorkflowStageEnum.getWorkflowStageByCode(mobileCheckDTO.getWorkflowStage()).getMessage(),statusMap.get(mobileCheckDTO.getWorkflowStatus())));
}
}
return null;
}
/**
* 协作人处理