|
@@ -2,17 +2,18 @@ package com.dayou.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.dayou.common.BaseEntity;
|
|
|
-import com.dayou.entity.BusinessReply;
|
|
|
-import com.dayou.entity.Message;
|
|
|
+import com.dayou.entity.*;
|
|
|
+import com.dayou.enums.MainBusinessEnum;
|
|
|
import com.dayou.mapper.MessageMapper;
|
|
|
import com.dayou.message.MessageTypeEnum;
|
|
|
import com.dayou.message.bo.BusinessMessageBO;
|
|
|
import com.dayou.message.bo.SystemMessageBO;
|
|
|
import com.dayou.message.handler.BusinessMessageHandler;
|
|
|
import com.dayou.message.handler.SystemMessageHandler;
|
|
|
-import com.dayou.service.IMessageService;
|
|
|
+import com.dayou.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.dayou.utils.LoginContext;
|
|
|
+import com.dayou.vo.CommissionDeclareVO;
|
|
|
import com.dayou.vo.ItemVO;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -42,6 +43,7 @@ import com.dayou.enums.BatchTaskTypeEnum;
|
|
|
import static com.dayou.enums.BusinessReplyEnum.MARKET_LOG_REPLY;
|
|
|
import static com.dayou.enums.BusinessReplyEnum.MARKET_VISIT_REPLY;
|
|
|
import static com.dayou.message.MessageTitle.*;
|
|
|
+import static com.dayou.message.MessageTitle.MAJOR_DECLARE_REMIND;
|
|
|
import static com.dayou.message.MessageTypeEnum.*;
|
|
|
|
|
|
/**
|
|
@@ -61,6 +63,18 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
|
|
|
@Autowired
|
|
|
private SystemMessageHandler systemMessageHandler;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICommissionDeclareService commissionDeclareService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMajorService majorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMajorProductionService majorProductionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserService userService;
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean packagingBusinessMessage(BusinessReply originalBO) {
|
|
|
BusinessMessageBO messageBO = new BusinessMessageBO();
|
|
@@ -91,6 +105,70 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Boolean packagingMajorDeclareRemind(Long declareId) {
|
|
|
+ BusinessMessageBO messageBO = new BusinessMessageBO();
|
|
|
+ CommissionDeclareVO declareVO = new CommissionDeclareVO();
|
|
|
+ CommissionDeclare originDeclare = commissionDeclareService.getById(declareId);
|
|
|
+ String businessType = originDeclare.getBusinessType();
|
|
|
+
|
|
|
+
|
|
|
+ String template = MAJOR_DECLARE_REMIND_CONTENT;
|
|
|
+ declareVO.setId(originDeclare.getId());
|
|
|
+
|
|
|
+ Major order = majorService.getOne(new LambdaQueryWrapper<Major>().select(Major::getClientManagerId, Major::getPrincipalId, Major::getOrderId, Major::getName)
|
|
|
+ .eq(BaseEntity::getId, originDeclare.getBusinessId()));
|
|
|
+ declareVO.setOrderName(order.getName());
|
|
|
+ if (originDeclare.getProductionId()!=null){
|
|
|
+ MajorProduction production = majorProductionService.getOne(new LambdaQueryWrapper<MajorProduction>().select(MajorProduction::getReportNo, MajorProduction::getName)
|
|
|
+ .eq(BaseEntity::getId, originDeclare.getProductionId()));
|
|
|
+ template = template.replace("name",production.getName());
|
|
|
+ declareVO.setName(production.getName());
|
|
|
+ declareVO.setReportNo(production.getReportNo());
|
|
|
+ }else {
|
|
|
+ template = template.replace("name",order.getName());
|
|
|
+ }
|
|
|
+ messageBO.setType(MessageTypeEnum.MAJOR_DECLARE_REMIND.name());
|
|
|
+ messageBO.setTitle(MAJOR_DECLARE_REMIND);
|
|
|
+ messageBO.setParams(JSON.toJSONString(declareVO));
|
|
|
+ if (MainBusinessEnum.COMMISSION_DECLARE_MAJOR_EVALUATE.name().equals(businessType)){
|
|
|
+ //评估人员向市场人员发 已申报情况不发送消息
|
|
|
+ int count = commissionDeclareService.count(new LambdaQueryWrapper<CommissionDeclare>()
|
|
|
+ .eq(CommissionDeclare::getBusinessType, MainBusinessEnum.COMMISSION_DECLARE_MAJOR_MARKET.name())
|
|
|
+ .eq(CommissionDeclare::getBusinessId, originDeclare.getBusinessId())
|
|
|
+ .eq(originDeclare.getProductionId()!=null,CommissionDeclare::getProductionId,originDeclare.getProductionId()));
|
|
|
+
|
|
|
+ if (count>0){
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ messageBO.setSender(originDeclare.getDeclareUserId());
|
|
|
+ messageBO.setReceiver(order.getClientManagerId());
|
|
|
+ String marketer = userService.getOne(new LambdaQueryWrapper<User>().select(User::getName).eq(BaseEntity::getId, order.getClientManagerId())).getName();
|
|
|
+ template = marketer + template;
|
|
|
+ messageBO.setMessage(template);
|
|
|
+ declareVO.setBusinessType(MainBusinessEnum.COMMISSION_DECLARE_MAJOR_MARKET.name());
|
|
|
+
|
|
|
+ }
|
|
|
+ if (MainBusinessEnum.COMMISSION_DECLARE_MAJOR_MARKET.name().equals(businessType)){
|
|
|
+ //评估人员向评估人员发
|
|
|
+ int count = commissionDeclareService.count(new LambdaQueryWrapper<CommissionDeclare>()
|
|
|
+ .eq(CommissionDeclare::getBusinessType, MainBusinessEnum.COMMISSION_DECLARE_MAJOR_EVALUATE.name())
|
|
|
+ .eq(CommissionDeclare::getBusinessId, originDeclare.getBusinessId())
|
|
|
+ .eq(originDeclare.getProductionId()!=null,CommissionDeclare::getProductionId,originDeclare.getProductionId()));
|
|
|
+ if (count>0){
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+ messageBO.setSender(originDeclare.getDeclareUserId());
|
|
|
+ messageBO.setReceiver(order.getPrincipalId());
|
|
|
+ String evaluator = userService.getOne(new LambdaQueryWrapper<User>().select(User::getName).eq(BaseEntity::getId, order.getPrincipalId())).getName();
|
|
|
+ template = evaluator + template;
|
|
|
+ messageBO.setMessage(template);
|
|
|
+ declareVO.setBusinessType(MainBusinessEnum.COMMISSION_DECLARE_MAJOR_EVALUATE.name());
|
|
|
+ }
|
|
|
+ messageBO.setParams(JSON.toJSONString(declareVO));
|
|
|
+ return businessMessageHandler.sendMessage(messageBO);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<Message> messageRedPoint() {
|
|
|
Long currentUserId = LoginContext.getCurrentUserId();
|
|
|
List<Message> list = this.list(new LambdaQueryWrapper<Message>().eq(Message::getReceiver, currentUserId)
|