Commit a98b1c5f by 崔彦峰

feat(clues): 新增二手车线索管理功能

- 创建 CluesController 提供线索分页列表和状态统计接口
- 实现线索分页查询功能,支持按状态、关键词等条件筛选
- 添加线索状态数量统计功能,统计待跟进、跟进中、暂败、成功收车数量
- 设计 CluesPadPageReq 请求对象,包含线索状态、关键词、销售人员等查询参数
- 创建 CluesPageResp 响应对象,包含线索基本信息、跟进状态等字段
- 实现 CluesService 业务逻辑层,集成 GSC 服务进行数据查询
- 添加 CluesStatusCountReq 和 CluesStatusCountResp 状态统计相关对象
- 集成登录用户信息获取,支持按销售用户和商户进行数据隔离
1 parent f8f933ae
package cn.com.glsx.stoassistant.controller.clues;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.scrm.system.model.wechatapplets.LoginUserInfoResponse;
import cn.com.glsx.stoassistant.request.clues.CluesPadPageReq;
import cn.com.glsx.stoassistant.request.clues.CluesStatusCountReq;
import cn.com.glsx.stoassistant.response.clues.CluesPageResp;
import cn.com.glsx.stoassistant.response.clues.CluesStatusCountResp;
import cn.com.glsx.stoassistant.service.clues.CluesService;
import cn.com.glsx.stoassistant.utils.Pagination;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.rop.util.RopThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Api("二手车线索管理")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@RestController
public class CluesController {
@Autowired
private CluesService cluesService;
@ApiOperation("车生活助手端线索分页列表")
@ServiceMethod(method = "scrm.api.stoassistant.clues.page", needInSession = NeedInSessionType.YES)
@PostMapping("/scrm.api.stoassistant.clues.page/1.0.0")
public RopResponse<Pagination<CluesPageResp>> page(CluesPadPageReq request) {
try {
if (request == null) {
return RopResponse.error("参数不能为空");
}
if (StringUtils.isBlank(request.getSellerUserId())) {
LoginUserInfoResponse loginUser = RopThreadLocal.getLoginUser(LoginUserInfoResponse.class);
request.setSellerUserId(loginUser.getUuid());
}
if (request.getSellerMerchantId() == null) {
LoginUserInfoResponse loginUser = RopThreadLocal.getLoginUser(LoginUserInfoResponse.class);
request.setSellerMerchantId(loginUser.getMerchantId());
}
return cluesService.page(request);
} catch (Exception e) {
log.error("车生活助手端线索分页查询失败", e);
return RopResponse.error(e.getMessage());
}
}
@ApiOperation("车生活助手端线索状态数量统计")
@ServiceMethod(method = "scrm.api.stoassistant.clues.statusCount", needInSession = NeedInSessionType.YES)
@PostMapping("/scrm.api.stoassistant.clues.statusCount/1.0.0")
public RopResponse<CluesStatusCountResp> statusCount(CluesStatusCountReq request) {
try {
if (request == null) {
return RopResponse.error("参数不能为空");
}
if (StringUtils.isBlank(request.getSellerUserId())) {
LoginUserInfoResponse loginUser = RopThreadLocal.getLoginUser(LoginUserInfoResponse.class);
request.setSellerUserId(loginUser.getUuid());
}
if (request.getSellerMerchantId() == null) {
LoginUserInfoResponse loginUser = RopThreadLocal.getLoginUser(LoginUserInfoResponse.class);
request.setSellerMerchantId(loginUser.getMerchantId());
}
return cluesService.statusCount(request);
} catch (Exception e) {
log.error("车生活助手端二手车线索状态数量统计查询失败", e);
return RopResponse.error(e.getMessage());
}
}
}
package cn.com.glsx.stoassistant.request.clues;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* PAD端线索分页列表查询请求
*/
@Data
@Schema(description = "PAD端线索分页列表查询请求")
public class CluesPadPageReq extends AbstractRopRequest implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "线索状态精准搜索:1-待跟进 2-跟进中 3-暂败 4-成功收车")
private Integer cluesStatus;
@Schema(description = "模糊搜索(线索编号/车主姓名/车主手机号/品牌车型)")
private String keyword;
@Schema(description = "销售人员ID,对应 seller_user_id")
private String sellerUserId;
@Schema(description = "转化用户ID(园区店),对应 conversion_user_id")
private String conversionUserId;
@Schema(description = "售商户号(4S店)")
private Integer sellerMerchantId;
@ApiModelProperty(notes = "当前页")
private long currentPage = 1;
@ApiModelProperty(notes = "每页数量")
private long pageSize = 10;
}
package cn.com.glsx.stoassistant.request.clues;
import com.rop.AbstractRopRequest;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 线索状态数量统计请求。
*/
@Data
@Schema(description = "线索状态数量统计请求")
public class CluesStatusCountReq extends AbstractRopRequest implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "销售商户号(4S店)")
private Integer sellerMerchantId;
@Schema(description = "销售人员ID,对应 seller_user_id")
private String sellerUserId;
}
package cn.com.glsx.stoassistant.response.clues;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 线索分页列表返回DTO(PAD/WEB 共用)
*/
@Data
@Schema(description = "线索分页列表返回对象")
public class CluesPageResp implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "线索ID")
private Integer id;
@Schema(description = "线索编号")
private String cluesNo;
@Schema(description = "录入时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date enterTime;
@Schema(description = "线索最新跟进时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date latestFollowTime;
@Schema(description = "线索门店(销售(4S店)商户名称)")
private String sellerMerchantName;
@Schema(description = "销售(4S店)商户ID")
private Integer sellerMerchantId;
@Schema(description = "销售名称")
private String sellerName;
@Schema(description = "车主名称")
private String carOwnerName;
@Schema(description = "车主电话")
private String carOwnerPhone;
@Schema(description = "车辆品牌")
private String carBrand;
@Schema(description = "子品牌名字")
private String carChildsBrandName;
@Schema(description = "车系名字")
private String carSeriesName;
@Schema(description = "车型名称")
private String carTypeName;
@Schema(description = "客户意向等级:A/B/C/D/O/H")
private String customerIntentLevel;
@Schema(description = "线索状态:1-待跟进 2-跟进中 3-暂败 4-成功收车")
private Integer cluesStatus;
@Schema(description = "跟进状态:0-正常 1-临期 2-已超期")
private Integer followTimeStatus;
@Schema(description = "下一次跟进时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date nextFollowTime;
@Schema(description = "评估师/转化人员名称")
private String conversionName;
}
package cn.com.glsx.stoassistant.response.clues;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 线索状态数量统计响应。
*/
@Data
@Schema(description = "线索状态数量统计响应")
public class CluesStatusCountResp implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "线索总数")
private Long totalCount;
@Schema(description = "待跟进数量,线索状态1")
private Long pendingFollowCount;
@Schema(description = "跟进中数量,线索状态2")
private Long followingCount;
@Schema(description = "暂败数量,线索状态3")
private Long tempLostCount;
@Schema(description = "成功收车数量,线索状态4")
private Long successCount;
}
package cn.com.glsx.stoassistant.service.clues;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.stoassistant.config.GSCServicePoolConfig;
import cn.com.glsx.stoassistant.constans.GSCServiceConstants;
import cn.com.glsx.stoassistant.request.clues.CluesPadPageReq;
import cn.com.glsx.stoassistant.request.clues.CluesStatusCountReq;
import cn.com.glsx.stoassistant.response.clues.CluesPageResp;
import cn.com.glsx.stoassistant.response.clues.CluesStatusCountResp;
import cn.com.glsx.stoassistant.utils.Pagination;
import cn.com.glsx.stoassistant.utils.SpringCloudHttpUtil;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Service
public class CluesService {
@Autowired
private GSCServicePoolConfig gscServicePoolConfig;
public RopResponse<Pagination<CluesPageResp>> page(CluesPadPageReq request) {
try {
// 获取指定服务的配置
GSCServicePoolConfig.GSCServiceParam serviceParam = gscServicePoolConfig.getServiceParam(GSCServiceConstants.GSC_VCP_PAD_FACADE);
// 构建请求参数
Map<String, Object> params = new HashMap<>();
params.put("cluesStatus", request.getCluesStatus());
params.put("keyword", request.getKeyword());
params.put("sellerUserId", request.getSellerUserId());
params.put("sellerMerchantId", request.getSellerMerchantId());
params.put("pageSize", request.getPageSize());
params.put("currentPage", request.getCurrentPage());
log.info("二手车线索分页查询调用服务:{},请求参数params:{}", GSCServiceConstants.GSC_VCP_PAD_FACADE, params);
// 调用指定服务的接口
String result = SpringCloudHttpUtil.post(
serviceParam,
params,
String.class,
"/clues/page",
null
);
log.info("二手车线索分页查询调用服务:{} 返回结果result:{}", GSCServiceConstants.GSC_VCP_PAD_FACADE, result);
// 解析返回结果
Map<String, Object> resultMap = JSON.parseObject(result, Map.class);
if (resultMap == null) {
throw new RuntimeException("调用服务失败:返回结果为空");
}
Integer code = (Integer) resultMap.get("code");
if (code == null || code != 0) {
String msg = (String) resultMap.get("msg");
throw new RuntimeException("调用服务失败:" + msg);
}
Map<String, Object> data = (Map<String, Object>) resultMap.get("data");
if (data == null) {
throw new RuntimeException("调用服务失败:data为空");
}
log.info("二手车线索分页查询调用服务:{},二手车线索分页查询,响应结果:{}", GSCServiceConstants.GSC_VCP_PAD_FACADE, data);
Pagination<CluesPageResp> pagination = new Pagination<>();
pagination.setPageNum((Integer) data.get("current"));
pagination.setPageSize((Integer) data.get("size"));
pagination.setCount((Integer) data.get("total"));
pagination.setData(JSON.parseArray(JSON.toJSONString(data.get("records")), CluesPageResp.class));
return RopResponse.success(pagination);
} catch (Exception e) {
log.error("二手车线索分页查询失败,服务:{}", GSCServiceConstants.GSC_VCP_PAD_FACADE, e);
throw new RuntimeException("二手车线索分页查询失败:" + e.getMessage(), e);
}
}
public RopResponse<CluesStatusCountResp> statusCount(CluesStatusCountReq request) {
try {
// 获取指定服务的配置
GSCServicePoolConfig.GSCServiceParam serviceParam = gscServicePoolConfig.getServiceParam(GSCServiceConstants.GSC_VCP_PAD_FACADE);
// 构建请求参数
Map<String, Object> params = new HashMap<>();
params.put("sellerUserId", request.getSellerUserId());
params.put("sellerMerchantId", request.getSellerMerchantId());
log.info("二手车线索状态数量统计调用服务:{},请求参数params:{}", GSCServiceConstants.GSC_VCP_PAD_FACADE, params);
// 调用指定服务的接口
String result = SpringCloudHttpUtil.post(
serviceParam,
params,
String.class,
"/clues/statusCount",
null
);
log.info("二手车线索状态数量统计调用服务:{} 返回结果result:{}", GSCServiceConstants.GSC_VCP_PAD_FACADE, result);
// 解析返回结果
Map<String, Object> resultMap = JSON.parseObject(result, Map.class);
if (resultMap == null) {
throw new RuntimeException("调用服务失败:返回结果为空");
}
Integer code = (Integer) resultMap.get("code");
if (code == null || code != 0) {
String msg = (String) resultMap.get("msg");
throw new RuntimeException("调用服务失败:" + msg);
}
Map<String, Object> data = (Map<String, Object>) resultMap.get("data");
if (data == null) {
throw new RuntimeException("调用服务失败:data为空");
}
log.info("二手车线索状态数量统计调用服务:{},二手车线索状态数量统计查询,响应结果:{}", GSCServiceConstants.GSC_VCP_PAD_FACADE, data);
CluesStatusCountResp cluesStatusCountResp = buildStatusCountResp(data);
return RopResponse.success(cluesStatusCountResp);
} catch (Exception e) {
log.error("二手车线索线索状态数量统计查询失败,服务:{}", GSCServiceConstants.GSC_VCP_PAD_FACADE, e);
throw new RuntimeException("二手车线索线索状态数量统计失败:" + e.getMessage(), e);
}
}
/**
* 构建二手车线索状态数量统计
*
* @param data
* @return
*/
private static CluesStatusCountResp buildStatusCountResp(Map<String, Object> data) {
CluesStatusCountResp response = new CluesStatusCountResp();
response.setTotalCount((Long) data.get("totalCount"));
response.setPendingFollowCount((Long) data.get("pendingFollowCount"));
response.setFollowingCount((Long) data.get("followingCount"));
response.setTempLostCount((Long) data.get("tempLostCount"));
response.setSuccessCount((Long) data.get("successCount"));
return response;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!