Commit f93220b6 authored by 潘志辉's avatar 潘志辉

Merge branch 'feature-0814-一汽大众查询留资互动列表接口' into 'master'

查询私信会话

See merge request !77
parents 099f3578 f1e794c2
package com.afanticar.afantiopenapi.controller;
import com.afanticar.afantiopenapi.mapper.OpenApiClientPrincipalRelationMapper;
import com.afanticar.afantiopenapi.model.BaseResponse;
import com.afanticar.afantiopenapi.model.dto.ImMessageDataDto;
import com.afanticar.afantiopenapi.model.dto.ImMessageRecordDto;
import com.afanticar.afantiopenapi.model.dto.ImMessageRequestDto;
import com.afanticar.afantiopenapi.model.dto.OpenIdDTO;
import com.afanticar.afantiopenapi.model.entity.LiveCrmCustomerChat;
import com.afanticar.afantiopenapi.service.BaseService;
import com.afanticar.afantiopenapi.service.LiveCrmCustomerChatService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/clue/im/message")
public class ClueImMessageController extends BaseController {
// 假设BaseService已经存在并被Spring管理
@Autowired
private BaseService baseService;
@Autowired
private LiveCrmCustomerChatService liveCrmCustomerChatService;
@Autowired
OpenApiClientPrincipalRelationMapper openApiClientPrincipalRelationMapper;
/**
* 查询互动列表
*/
@PostMapping("/list")
public BaseResponse<ImMessageDataDto> list(@RequestBody ImMessageRequestDto request) {
// 添加频率控制,使用日期类型、限制次数和限制周期参数
BaseResponse check = baseService.baseLimit("im_message_list", 100, 60);
if (check != null) {
return check;
}
// 根据 request.getStoreCode()和request.getPhoneNo()找到AuthorOpenId和FansOpenId
List<OpenIdDTO> openIdDTOList = openApiClientPrincipalRelationMapper.getOpenIdByStoreCodeAndPhone(request.getStoreCode(), request.getPhoneNo());
if(CollectionUtils.isEmpty(openIdDTOList)){
return success(new ImMessageDataDto());
}
// 使用分页查询表数据返回
Page<LiveCrmCustomerChat> page = new Page<>(request.getCurrent(), request.getSize());
LambdaQueryWrapper<LiveCrmCustomerChat> queryWrapper = new LambdaQueryWrapper<>();
openIdDTOList.forEach(openIdDTO -> {
queryWrapper.or().eq(LiveCrmCustomerChat::getAuthorOpenId, openIdDTO.getAuthorOpenId())
.eq(LiveCrmCustomerChat::getFansOpenId, openIdDTO.getUserOpenId());
});
if ("desc".equals(request.getTimeSort())) {
queryWrapper.orderByDesc(LiveCrmCustomerChat::getPublishTime);
}
Page<LiveCrmCustomerChat> iPageData = liveCrmCustomerChatService.page(page, queryWrapper);
ImMessageDataDto imMessageDataDto = new ImMessageDataDto();
imMessageDataDto.setTotal(iPageData.getTotal());
imMessageDataDto.setCurrent(iPageData.getCurrent());
imMessageDataDto.setSize(iPageData.getSize());
imMessageDataDto.setPages(iPageData.getPages());
List< ImMessageRecordDto> imMessageRecordDtos = new ArrayList<>();
iPageData.getRecords().forEach(liveCrmCustomerChat -> {
ImMessageRecordDto imMessageRecordDto = new ImMessageRecordDto();
imMessageRecordDto.setAuthorNickname(liveCrmCustomerChat.getAuthorNickname());
imMessageRecordDto.setAuthorAvatar(liveCrmCustomerChat.getAuthorAvatar());
imMessageRecordDto.setCustomerNickname(liveCrmCustomerChat.getFansNickname());
imMessageRecordDto.setCustomerAvatar(liveCrmCustomerChat.getFansAvatar());
imMessageRecordDto.setIsAuthorSend(liveCrmCustomerChat.getIsAuthorSend());
imMessageRecordDto.setMessageTime(liveCrmCustomerChat.getPublishTime());
imMessageRecordDto.setContent(liveCrmCustomerChat.getContent());
imMessageRecordDtos.add(imMessageRecordDto);
});
imMessageDataDto.setRecords(imMessageRecordDtos);
return success(imMessageDataDto);
}
}
\ No newline at end of file
package com.afanticar.afantiopenapi.mapper;
import com.afanticar.afantiopenapi.model.entity.LiveCrmCustomerChat;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* @author liuyudong
* @desc
* @Date 2023/08/08
**/
@Repository
public interface LiveCrmCustomerChatMapper extends BaseMapper<LiveCrmCustomerChat> {
}
package com.afanticar.afantiopenapi.mapper;
import com.afanticar.afantiopenapi.model.dto.OpenIdDTO;
import com.afanticar.afantiopenapi.model.entity.OpenApiClientPrincipalRelationEntity;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -12,6 +14,7 @@ import java.util.List;
* @since 2025/4/24 9:47
*/
@Mapper
@DS("master")
public interface OpenApiClientPrincipalRelationMapper extends BaseMapper<OpenApiClientPrincipalRelationEntity> {
/**
......@@ -22,4 +25,9 @@ public interface OpenApiClientPrincipalRelationMapper extends BaseMapper<OpenApi
* @param clientId 客户端id
*/
List<OpenApiClientPrincipalRelationEntity> selectByClientId(@Param("clientId") String clientId);
/**
* 查询留资主播和粉丝open_id
*/
List<OpenIdDTO> getOpenIdByStoreCodeAndPhone(@Param("storeCode") String storeCode, @Param("phone") String phone);
}
package com.afanticar.afantiopenapi.model.dto;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
import java.util.List;
@Data
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class ImMessageDataDto {
private long current;
private long size;
private long pages;
private long total;
private List<ImMessageRecordDto> records;
}
\ No newline at end of file
package com.afanticar.afantiopenapi.model.dto;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
import java.util.Date;
@Data
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class ImMessageRecordDto {
private String authorNickname;
private String authorAvatar;
private String customerNickname;
private String customerAvatar;
private int isAuthorSend;
private Date messageTime;
private String content;
}
\ No newline at end of file
package com.afanticar.afantiopenapi.model.dto;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@JSONType(naming = com.alibaba.fastjson.PropertyNamingStrategy.SnakeCase)
public class ImMessageRequestDto {
private String storeCode;
private String phoneNo;
private String timeSort = "desc";
private int current = 1;
private int size = 10;
}
\ No newline at end of file
package com.afanticar.afantiopenapi.model.dto;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@JsonNaming(value = com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy.class)
@JSONType(naming = com.alibaba.fastjson.PropertyNamingStrategy.SnakeCase)
public class OpenIdDTO {
private String authorOpenId;
private String userOpenId;
private int platform;
}
package com.afanticar.afantiopenapi.model.entity;
//import com.afanticar.marketing.onedata.domain.dto.MatrixMessageDto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* @author liuyudong
* @desc
* @Date 2023/08/08
**/
@TableName(value ="live_crm_customer_chat_all")
@Data
public class LiveCrmCustomerChat {
/**
* 私信历史记录主键id
*/
@TableId(type = IdType.INPUT)
private String id;
/**
* fans_open_id
*/
private String fansOpenId;
/**
* fans_nickname
*/
private String fansNickname;
/**
* author_open_id
*/
private String authorOpenId;
/**
* author_id
*/
private String authorId;
/**
* content
*/
private String content;
/**
* 私信的发送者,0粉丝,1主播
*/
private Integer isAuthorSend;
/**
* 是否已读,0未读,1已读
*/
private Integer isRead;
/**
* 创建时间
*/
private Date ctime;
/**
* 联系方式
*/
private String contact;
/**
* 车型名称字符串拼接,以逗号分隔
*/
private String seriesId;
/**
* fans_id
*/
private String fansId;
/**
* fans_avatar
*/
private String fansAvatar;
/**
* 抖音快手的code
*/
private String fansCode;
/**
* author_nickname
*/
private String authorNickname;
/**
* author_avatar
*/
private String authorAvatar;
/**
* 实际私信时间
*/
private Date publishTime;
/**
* 平台私信id
*/
private String msgId;
/**
* 风火轮使用人名称
*/
private String userName;
/**
* 会话id
*/
private String shortId;
/**
* 进入私信回话 0-否 1-是
*/
private String isEnterDirect;
/**
* 外部信息(包含:表情url、视频itemid、卡片信息)
*/
private String externalInfo;
/**
* 消息类型(1:文本;2:图片;3:表情;4:视频;5:消息卡片;6:其他;) ) engine = distributed( default , marketing_rawdata , live_crm_customer_chat_local , hivehash(id)
*/
private Integer messageType;
private Integer isDouyinSend;
private Integer reachFunctionType;
/**
* 主体id
*/
private String principalId;
/**
* 主体名称
*/
private String principalName;
/**
* 一级区域id
*/
private String regionId;
/**
* 一级区域名称
*/
private String regionName;
/**
* 二级区域id
*/
private String villageId;
/**
* 二级区域名称
*/
private String villageName;
/**
* 成员ID
*/
private String memberId;
/**
* 成员编号
*/
private String memberCode;
/**
* 成员名称
*/
private String memberName;
/**
* 策略id
*/
private String sceneId;
/**
* 策略名称
*/
private String sceneName;
/**
* 触发抖音发送不成功错误描述记录
*/
private String errorMsg;
private Integer functionType=0;
// public void setMatrix(MatrixMessageDto dto){
// if(dto != null){
// this.principalId = dto.getPrincipalId();
// this.principalName = dto.getPrincipalName();
// this.regionId = dto.getRegionId();
// this.regionName = dto.getRegionName();
// this.villageId = dto.getVillageId();
// this.villageName = dto.getVillageName();
// this.memberId = dto.getMemberId();
// this.memberCode = dto.getMemberCode();
// this.memberName = dto.getMemberName();
// }
// }
}
package com.afanticar.afantiopenapi.service;
import com.afanticar.afantiopenapi.model.entity.LiveCrmCustomerChat;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author liuyudong
* @desc
* @Date 2023/08/08
**/
public interface LiveCrmCustomerChatService extends IService<LiveCrmCustomerChat> {
}
package com.afanticar.afantiopenapi.service.impl;
import com.afanticar.afantiopenapi.mapper.LiveCrmCustomerChatMapper;
import com.afanticar.afantiopenapi.model.entity.LiveCrmCustomerChat;
import com.afanticar.afantiopenapi.service.LiveCrmCustomerChatService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* @author liuyudong
* @desc
* @Date 2023/08/08
**/
@Service
@DS("marketing")
public class LiveCrmCustomerChatServiceImpl extends ServiceImpl<LiveCrmCustomerChatMapper, LiveCrmCustomerChat> implements LiveCrmCustomerChatService {
}
......@@ -15,6 +15,7 @@ spring:
- data-id: dynamic-db-afanti-bi-app-vault.yml
- data-id: dynamic-db-afanti-vault.yml
- data-id: dynamic-db-afanti-tmp-vault.yml
- data-id: dynamic-db-afanti-bsck-marketing.yml
- data-id: common-redis.yml
- data-id: afanti-open-api.yml
vault:
......@@ -52,6 +53,12 @@ spring:
role: external-role
username-property: spring.datasource.dynamic.datasource.tmp.username
password-property: spring.datasource.dynamic.datasource.tmp.password
marketing:
enabled: true
backend: ${spring.profiles.active}db
role: app-role
username-property: spring.datasource.dynamic.datasource.marketing.username
password-property: spring.datasource.dynamic.datasource.marketing.password
#
#
......@@ -90,4 +97,4 @@ mybatis-plus:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
logging:
level:
com.afanticar.datacenter.http.mapper.*: debug
\ No newline at end of file
com.afanticar.afantiopenapi.mapper.*: debug
\ No newline at end of file
......@@ -5,4 +5,11 @@
resultType="com.afanticar.afantiopenapi.model.entity.OpenApiClientPrincipalRelationEntity">
select * from open_api_client_principal_relation where client_id = #{clientId} and is_deleted = 0
</select>
<select id="getOpenIdByStoreCodeAndPhone"
resultType="com.afanticar.afantiopenapi.model.dto.OpenIdDTO">
select distinct author_open_id ,user_open_id,platform from fhl_mkms_clue_follow_up lea
inner join base_dealer dea on lea.dealer_id = dea.id and dea.status=1 and dea.is_deleted =0 and dea.store_code =#{storeCode}
where lea.contact =#{phone} and lea.is_deleted = 0
</select>
</mapper>
\ No newline at end of file
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