Commit 4224ccb5 by 王祖波

通过消息队列批量保存跟进记录

parent 342c6371
package com.gic.haoban.manage.api.qdto.contact;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
public class ContactFollowBatchQDTO implements Serializable {
private static final long serialVersionUID = 973688857967269974L;
/**
* 会员id
*/
private List<String> memberIdList;
/**
* 导购id
*/
private String clerkId;
/**
* 跟进记录
*/
private String followRemark;
/**
* 跟进时间
*/
private Date followTime;
public List<String> getMemberIdList() {
return memberIdList;
}
public void setMemberIdList(List<String> memberIdList) {
this.memberIdList = memberIdList;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getFollowRemark() {
return followRemark;
}
public void setFollowRemark(String followRemark) {
this.followRemark = followRemark;
}
public Date getFollowTime() {
return followTime;
}
public void setFollowTime(Date followTime) {
this.followTime = followTime;
}
}
\ No newline at end of file
......@@ -25,6 +25,12 @@ public interface ContactFollowApiService {
ServiceResponse<Void> saveBatchFollow(List<ContactFollowQDTO> list);
/**
* 通过消息队列批量保存跟进记录
* @param message
* @return
*/
ServiceResponse<Void> saveBatchFollowForMQ(String message);
/**
* 跟进记录列表查询
* @param enterpriseId
* @param searchQDTO
......
package com.gic.haoban.manage.service.service.out.impl.contact;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.manage.api.dto.contact.ContactFollowDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowBatchQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowQDTO;
import com.gic.haoban.manage.api.qdto.contact.ContactFollowSearchQDTO;
import com.gic.haoban.manage.api.service.contact.ContactFollowApiService;
import com.gic.haoban.manage.service.service.contact.ContactFollowService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by wangzubo on 2022/11/1.
......@@ -22,6 +32,8 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService {
@Autowired
private ContactFollowService contactFollowService;
@Autowired
private ClerkService clerkService;
@Override
public ServiceResponse<Void> saveFollow(ContactFollowQDTO qdto) {
......@@ -36,6 +48,38 @@ public class ContactFollowApiServiceImpl implements ContactFollowApiService {
}
@Override
public ServiceResponse<Void> saveBatchFollowForMQ(String message) {
if (StringUtils.isBlank(message)) {
return ServiceResponse.success();
}
ContactFollowBatchQDTO qdto = JSONObject.parseObject(message, ContactFollowBatchQDTO.class);
List<String> memberIdList = qdto.getMemberIdList();
if (CollectionUtils.isEmpty(memberIdList)) {
return ServiceResponse.success();
}
String clerkId = qdto.getClerkId();
if (StringUtils.isBlank(clerkId)) {
return ServiceResponse.success();
}
ClerkDTO clerkDTO = clerkService.getclerkById(clerkId);
if (clerkDTO == null) {
return ServiceResponse.success();
}
List<ContactFollowQDTO> list = memberIdList.stream().map(x -> {
ContactFollowQDTO followQDTO = new ContactFollowQDTO();
followQDTO.setMemberId(x);
followQDTO.setClerkId(clerkId);
followQDTO.setClerkCode(clerkDTO.getClerkCode());
followQDTO.setFollowRemark(clerkDTO.getClerkName() + qdto.getFollowRemark());
followQDTO.setFollowTime(qdto.getFollowTime());
followQDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
return followQDTO;
}).collect(Collectors.toList());
saveBatchFollow(list);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Page<ContactFollowDTO>> pageFollow(String enterpriseId, ContactFollowSearchQDTO searchQDTO, BasePageInfo pageInfo) {
Page<ContactFollowDTO> page = contactFollowService.pageFollow(enterpriseId, searchQDTO, pageInfo);
return ServiceResponse.success(page);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment