diff --git a/doc/v1.1.3/sql.sql b/doc/v1.1.3/sql.sql new file mode 100644 index 0000000..73a270c --- /dev/null +++ b/doc/v1.1.3/sql.sql @@ -0,0 +1,61 @@ +alter table follow_record_log + add task_id bigint null comment '跟进任务id' after id; + +update follow_record_log t1 +set task_id = (select w1.task_id from follow_record w1 where w1.id = t1.record_id) +where t1.task_id is null; + + +create table secret_report_history +( + id bigint auto_increment, + task_id bigint not null comment '任务id', + task_type int(3) not null comment '跟进类型 ', + follow_record_id bigint not null comment '跟进记录id', + first_call tinyint(1) not null comment '是否是首次通话', + call_id varchar(225) not null comment '通话记录id', + staff_id bigint not null comment '工作人员id', + staff_name varchar(64) null comment '工作人员名称', + customer_id bigint not null comment '客户id', + call_type int(3) not null comment '主/被叫', + call_time datetime not null comment '呼叫时间', + call_duration bigint null comment '通话时长(秒)', + shop_id bigint not null comment '门店id', + group_id bigint not null comment '集团id', + constraint secret_report_history_pk + primary key (id) +) + comment '智能电话通话记录'; + +create index secret_report_history_call_time_index + on secret_report_history (call_time); + +create index secret_report_history_customer_id_index + on secret_report_history (customer_id); + +create index secret_report_history_staff_id_index + on secret_report_history (staff_id); + + + + +-- 报表字段调整 +alter table cas_015_d + add i10 int null comment '智能电话跟进有效数'; +alter table cas_015_d + add i11 int null comment '智能电话跟进数'; +alter table cas_015_d + add i12 int null comment '首次智能电话跟进有效数'; +alter table cas_015_d + add i13 int null comment '首次智能电话跟进数'; + + + +alter table cas_015_m + add i10 int null comment '智能电话跟进有效数'; +alter table cas_015_m + add i11 int null comment '智能电话跟进数'; +alter table cas_015_m + add i12 int null comment '首次智能电话跟进有效数'; +alter table cas_015_m + add i13 int null comment '首次智能电话跟进数'; \ No newline at end of file diff --git a/fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java b/fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java new file mode 100644 index 0000000..f039209 --- /dev/null +++ b/fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/SecretReportHistoryMapper.java @@ -0,0 +1,37 @@ +package cn.fw.valhalla.dao.mapper; + +import cn.fw.valhalla.domain.db.SecretReportHistory; +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO; +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author : kurisu + * @className : SecretReportHistoryMapper + * @description : 通话记录mapper + * @date: 2021-02-21 14:54 + */ +@Repository +public interface SecretReportHistoryMapper extends BaseMapper { + /** + * 查询通话记录池 + * + * @param startIndex + * @param pageSize + * @param queryVO + * @return + */ + List secretReportList(@Param("startIndex") Integer startIndex, @Param("pageSize") Integer pageSize, @Param("condition") SecretReportHistoryQuery queryVO); + + /** + * 查询通话记录总数 + * + * @param queryVO + * @return + */ + Long secretReportCount(@Param("condition") SecretReportHistoryQuery queryVO); +} diff --git a/fw-valhalla-dao/src/main/resources/mapper/FollowTaskMapper.xml b/fw-valhalla-dao/src/main/resources/mapper/FollowTaskMapper.xml index 835991a..35c8d74 100644 --- a/fw-valhalla-dao/src/main/resources/mapper/FollowTaskMapper.xml +++ b/fw-valhalla-dao/src/main/resources/mapper/FollowTaskMapper.xml @@ -9,6 +9,7 @@ SELECT t1.id, if(t1.type=3 , t4.plate_no, t3.plate_no)plate_no, if(t1.type=3 , t4.frame_no, t3.frame_no)frame_no, + t3.cus_level cus_level, t2.expires loan_expires, t1.type type, t1.follow_user user_id, diff --git a/fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml b/fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml new file mode 100644 index 0000000..1243c02 --- /dev/null +++ b/fw-valhalla-dao/src/main/resources/mapper/SecretReportHistoryMapper.xml @@ -0,0 +1,112 @@ + + + + + + + + diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java new file mode 100644 index 0000000..1c8ae2f --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/SecretReportHistory.java @@ -0,0 +1,74 @@ +package cn.fw.valhalla.domain.db; + +import cn.fw.common.data.entity.BaseEntity; +import cn.fw.valhalla.domain.enums.CallTypeEnum; +import cn.fw.valhalla.domain.enums.FollowTypeEnum; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Date; + +/** + * @author : kurisu + * @className : SecretReportHistory + * @description : 通话记录 + * @date: 2021-02-21 11:41 + */ +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class SecretReportHistory extends BaseEntity { + /** + * 任务id + */ + private Long taskId; + /** + * 跟进类型 + */ + private FollowTypeEnum taskType; + /** + * 跟进id + */ + private Long followRecordId; + /** + * 是否首次通话(针对跟进任务来说) + */ + private Boolean firstCall; + /** + * 通话id + */ + private String callId; + /** + * 工作人员id + */ + private Long staffId; + /** + * 工作人员名称 + */ + private String staffName; + /** + * 客户id + */ + private Long customerId; + /** + * 呼叫类型 + */ + private CallTypeEnum callType; + /** + * 呼叫时间 + */ + private Date callTime; + /** + * 通话时长 + */ + private Long callDuration; + /** + * 门店id + */ + private Long shopId; + /** + * 集团id + */ + private Long groupId; +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/follow/FollowRecordLog.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/follow/FollowRecordLog.java index 5093273..6367a81 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/follow/FollowRecordLog.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/follow/FollowRecordLog.java @@ -21,6 +21,10 @@ public class FollowRecordLog extends BaseEntity { */ private Long recordId; /** + * 任务id + */ + private Long taskId; + /** * 附件类型 */ private AttTypeEnum attType; diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/AccidentPoolDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/AccidentPoolDTO.java index 39e80a7..b97b8c2 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/AccidentPoolDTO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/AccidentPoolDTO.java @@ -29,6 +29,7 @@ public class AccidentPoolDTO { /** * 报案手机号 */ + @NotBlank(message = "报案手机号不能为空") private String reportMobile; /** * 车牌号 diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java index 938a14f..91029c6 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CallReportDTO.java @@ -1,5 +1,6 @@ package cn.fw.valhalla.domain.dto; +import cn.fw.valhalla.domain.enums.CallTypeEnum; import lombok.Data; import java.time.LocalDateTime; @@ -22,6 +23,10 @@ public class CallReportDTO { */ private Long staffId; /** + * 工作人员名称 + */ + private String staffName; + /** * 用户号码 */ private String staffMobile; @@ -38,6 +43,10 @@ public class CallReportDTO { */ private Long talkTime; /** + * 呼叫类型 + */ + private CallTypeEnum dialType; + /** * 集团id */ private Long groupId; diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CustomerDetailDto.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CustomerDetailDto.java index db7ad61..eaf53f1 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CustomerDetailDto.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CustomerDetailDto.java @@ -138,6 +138,10 @@ public class CustomerDetailDto { */ private String idCode; /** + * 进站次数 + */ + private Integer arrivalCount; + /** * 上次进站时间 */ private Date arrivalTime; diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/FollowPoolDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/FollowPoolDTO.java index 5c35250..66cb86a 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/FollowPoolDTO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/FollowPoolDTO.java @@ -17,6 +17,10 @@ public class FollowPoolDTO { */ private String plateNo; /** + * 客户星级 + */ + private Integer cusLevel; + /** * 车架号 */ private String frameNo; diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/LeaveAllocationDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/LeaveAllocationDTO.java index ff76ca0..7cb8ca9 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/LeaveAllocationDTO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/LeaveAllocationDTO.java @@ -3,7 +3,11 @@ package cn.fw.valhalla.domain.dto; import cn.fw.valhalla.common.enums.AllocationTypeEnum; import lombok.Data; +import javax.validation.Valid; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.util.List; /** * @author : kurisu @@ -15,26 +19,70 @@ import javax.validation.constraints.NotNull; public class LeaveAllocationDTO { @NotNull(message = "记录id不能为空") private Long id; - - @NotNull(message = "分配方式不能为空") - private Integer allocationType; - /** - * 指定人员id + * 分配规则 */ - private Long userId; + @Valid + @NotEmpty(message = "分配规则不能为空") + private List ruleList; - /** - * 门店id (前端无关) - */ - private Long shopId; /** - * 分配方式 (前端无关) - */ - private AllocationTypeEnum type; - /** - * 顾问id (前端无关) + * 原始顾问id (前端无关) */ private Long adviserId; + + public static class Allocation { + /** + * 指定人员id + */ + @NotNull(message = "人员id不能为空") + private Long userId; + /** + * 人员名称 + */ + private String userName; + /** + * 指定人员id + */ + @Min(value = 1, message = "保有客数量必须大于0") + private Integer num; + + /** + * 门店id (前端无关) + */ + private Long shopId; + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Long getShopId() { + return shopId; + } + + public void setShopId(Long shopId) { + this.shopId = shopId; + } + } } diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/RoleChangeDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/RoleChangeDTO.java new file mode 100644 index 0000000..27f41f3 --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/RoleChangeDTO.java @@ -0,0 +1,31 @@ +package cn.fw.valhalla.domain.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * @author : kurisu + * @className : RoleChangeDTO + * @description : 角色变动dto + * @date: 2021-02-20 15:11 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class RoleChangeDTO { + /** + * 门店 + */ + private Long shopId; + /** + * 用户id + */ + private Long userId; + /** + * 用户名称 + */ + private String userName; +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java new file mode 100644 index 0000000..a23b620 --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/SecretReportHistoryDTO.java @@ -0,0 +1,76 @@ +package cn.fw.valhalla.domain.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * @author : kurisu + * @className : SecretReportHistoryDTO + * @description : + * @date: 2021-02-21 15:47 + */ +@Data +public class SecretReportHistoryDTO { + private Long id; + /** + * 任务id + */ + private Long taskId; + /** + * 跟进类型 + */ + private Integer followType; + /** + * 跟进id + */ + private Long followRecordId; + /** + * 是否首次通话(针对跟进任务来说) + */ + private Boolean firstCall; + /** + * 通话id + */ + private String callId; + /** + * 工作人员id + */ + private Long staffId; + /** + * 工作人员名称 + */ + private String staffName; + /** + * 客户id + */ + private Long customerId; + /** + * 客户名称 + */ + private String customerName; + /** + * 车牌号 + */ + private String plateNo; + /** + * 呼叫类型 + */ + private Integer dialType; + /** + * 呼叫时间 + */ + private Date callTime; + /** + * 通话时长 + */ + private Long callDuration; + /** + * 门店id + */ + private Long shopId; + /** + * 集团id + */ + private Long groupId; +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java new file mode 100644 index 0000000..28a0a04 --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/CallTypeEnum.java @@ -0,0 +1,78 @@ +package cn.fw.valhalla.domain.enums; + +import com.baomidou.mybatisplus.core.enums.IEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; + +/** + * @author : kurisu + * @className : CallTypeEnum + * @description : 呼叫类型 + * @date: 2020-08-11 17:37 + */ +public enum CallTypeEnum implements IEnum { + /** + * 主叫 + */ + CALL(0, "主叫"), + /** + * 被叫 + */ + P_CALL(1, "被叫"), + ; + + /** + * 值 + */ + private final Integer value; + /** + * 名称 + */ + @Getter + private final String name; + + CallTypeEnum(final Integer value, final String name) { + this.value = value; + this.name = name; + } + + /** + * 根据枚举值获取枚举对象 + */ + @JsonCreator + public static CallTypeEnum ofValue(final Integer value) { + for (final CallTypeEnum typeEnum : CallTypeEnum.values()) { + if (typeEnum.value.equals(value)) { + return typeEnum; + } + } + return null; + } + + /** + * 获取值 + * + * @return 值 + */ + @JsonValue + @Override + public Integer getValue() { + return value; + } + + /** + * 获取描述 + * + * @return 值 + */ + @JsonCreator + public static String getNameByVale(final Integer value) { + for (final CallTypeEnum typeEnum : CallTypeEnum.values()) { + if (typeEnum.value.equals(value)) { + return typeEnum.getName(); + } + } + return ""; + } +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java new file mode 100644 index 0000000..f12ed80 --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/SecretReportHistoryQuery.java @@ -0,0 +1,73 @@ +package cn.fw.valhalla.domain.query; + +import cn.fw.common.validator.EnumValue; +import cn.fw.valhalla.common.utils.DateUtil; +import cn.fw.valhalla.domain.enums.CallTypeEnum; +import cn.fw.valhalla.domain.enums.FollowTypeEnum; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; + +/** + * @author : kurisu + * @className : SecretReportHistoryQuery + * @description : 查询条件 + * @date: 2021-02-21 15:55 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@ToString(callSuper = true) +public class SecretReportHistoryQuery extends PoolQuery { + @EnumValue(enumClass = FollowTypeEnum.class, message = "跟进类型不正确") + private Integer taskType; + + /** + * 主叫/被叫 + */ + @EnumValue(enumClass = CallTypeEnum.class, message = "主被叫类型不正确") + private Integer callType; + + /** + * 通话时间段(区间) + */ + private String callTime; + /** + * 客户名称 + */ + private String customerName; + + + public Date getStartTime1() { + if (StringUtils.isBlank(callTime)) { + return null; + } + String[] times = callTime.split(","); + if (StringUtils.isNotBlank(times[0]) && NumberUtils.isDigits(times[0])) { + LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(times[0])).atZone(ZoneId.systemDefault()).toLocalDateTime(); + return DateUtil.getBeginInTime(DateUtil.localDateTime2Date(localDateTime)); + } + return null; + } + + public Date getStartTime2() { + if (StringUtils.isBlank(callTime)) { + return null; + } + String[] times = callTime.split(","); + if (times.length < TIME_STR_LENGTH) { + return null; + } + if (StringUtils.isNotBlank(times[1]) && NumberUtils.isDigits(times[1])) { + LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(times[1])).atZone(ZoneId.systemDefault()).toLocalDateTime(); + return DateUtil.getEndInTime(DateUtil.localDateTime2Date(localDateTime)); + } + return null; + } +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/PostUserVO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/PostUserVO.java index 51e1bcd..569b7a5 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/PostUserVO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/PostUserVO.java @@ -23,4 +23,8 @@ public class PostUserVO implements Serializable { * 用户姓名 */ private String userName; + /** + * 当前保有客数 + */ + private Integer curQuantity; } diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java new file mode 100644 index 0000000..ffae859 --- /dev/null +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/SecretReportHistoryVO.java @@ -0,0 +1,89 @@ +package cn.fw.valhalla.domain.vo; + +import cn.fw.valhalla.domain.enums.CallTypeEnum; +import lombok.Data; + +import java.util.Date; +import java.util.Objects; + +/** + * @author : kurisu + * @className : SecretReportHistoryVO + * @description : 智能通话池 + * @date: 2021-02-21 15:40 + */ +@Data +public class SecretReportHistoryVO { + private Long id; + /** + * 任务id + */ + private Long taskId; + /** + * 跟进类型 + */ + private Integer followType; + /** + * 跟进id + */ + private Long followRecordId; + /** + * 是否首次通话(针对跟进任务来说) + */ + private Boolean firstCall; + /** + * 通话id + */ + private String callId; + /** + * 工作人员id + */ + private Long staffId; + /** + * 工作人员名称 + */ + private String staffName; + /** + * 客户id + */ + private Long customerId; + /** + * 客户名称 + */ + private String customerName; + /** + * 车牌号 + */ + private String plateNo; + /** + * 呼叫类型 + */ + private CallTypeEnum callType; + /** + * 呼叫时间 + */ + private Date callTime; + /** + * 通话时长 + */ + private Long callDuration; + /** + * 门店id + */ + private Long shopId; + /** + * 门店名称 + */ + private String shopName; + /** + * 集团id + */ + private Long groupId; + + public String getCallTypeDesc() { + if (Objects.isNull(callType)) { + return null; + } + return callType.getName(); + } +} diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/follow/FollowDetailVO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/follow/FollowDetailVO.java index 2b126e2..23fd7aa 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/follow/FollowDetailVO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/follow/FollowDetailVO.java @@ -53,6 +53,18 @@ public class FollowDetailVO { */ private String tags; /** + * 跟进次数 + */ + private Integer times; + /** + * 客户星级 + */ + private Integer cusLevel; + /** + * 进站次数 + */ + private Integer arrivalCount; + /** * 所属服务顾问 */ private Long adviserId; diff --git a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/pool/FollowPoolListVO.java b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/pool/FollowPoolListVO.java index 8a59d09..b0e3697 100644 --- a/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/pool/FollowPoolListVO.java +++ b/fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/pool/FollowPoolListVO.java @@ -19,6 +19,10 @@ public class FollowPoolListVO { */ private String plateNo; /** + * 客户星级 + */ + private Integer cusLevel; + /** * 车架号 */ private String frameNo; diff --git a/fw-valhalla-sdk/pom.xml b/fw-valhalla-sdk/pom.xml index 4efa15e..52bec6a 100644 --- a/fw-valhalla-sdk/pom.xml +++ b/fw-valhalla-sdk/pom.xml @@ -10,7 +10,7 @@ ../pom.xml fw-valhalla-sdk - 1.1.1 + 1.1.3 jar fw-valhalla-sdk diff --git a/fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/api/CustomerApiService.java b/fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/api/CustomerApiService.java index 3449b7c..1565a63 100644 --- a/fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/api/CustomerApiService.java +++ b/fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/api/CustomerApiService.java @@ -2,6 +2,7 @@ package cn.fw.valhalla.sdk.api; import cn.fw.data.base.domain.common.Message; import cn.fw.valhalla.sdk.param.ChangeAdviserReq; +import cn.fw.valhalla.sdk.param.ChangePlateNoReq; import cn.fw.valhalla.sdk.param.CustomerParams; import cn.fw.valhalla.sdk.result.CustomerContactDto; import cn.fw.valhalla.sdk.result.CustomerInfoDto; @@ -88,7 +89,7 @@ public interface CustomerApiService { * @return 是否变更成功 */ @PostMapping("/change/adviser") - Message changeAdviser(@RequestBody ChangeAdviserReq changeAdviserReq); + Message changeAdviser(@Valid @RequestBody ChangeAdviserReq changeAdviserReq); /** * 会员关联商家(专属商家和进站的商家) @@ -140,4 +141,12 @@ public interface CustomerApiService { */ @GetMapping("/queryReceivable") Message queryReceivable(@RequestParam("userId") Long userId, @RequestParam("plateNo") String plateNo); + + /** + * 修改车牌号 + * @param changePlateNoReq + * @return + */ + @PostMapping("/updatePlateNo") + Message updatePlateNo(@Valid @RequestBody ChangePlateNoReq changePlateNoReq); } diff --git a/fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/param/ChangePlateNoReq.java b/fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/param/ChangePlateNoReq.java new file mode 100644 index 0000000..70ef60c --- /dev/null +++ b/fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/param/ChangePlateNoReq.java @@ -0,0 +1,35 @@ +package cn.fw.valhalla.sdk.param; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * 修改车牌号 + * @author kurisu + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ToString +public class ChangePlateNoReq { + /** + * 车架号 + */ + @NotBlank(message = "车架号不能为空") + private String frameNo; + /** + * 车牌号 + */ + @NotBlank(message = "车牌号不能为空") + private String plateNo; + /** + * 集团id + */ + @NotNull(message = "集团id不能为空") + private Long groupId; +} diff --git a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/api/CustomerApiServiceImpl.java b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/api/CustomerApiServiceImpl.java index efd26af..a864606 100644 --- a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/api/CustomerApiServiceImpl.java +++ b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/api/CustomerApiServiceImpl.java @@ -4,6 +4,7 @@ import cn.fw.data.base.domain.common.Message; import cn.fw.valhalla.domain.dto.CustomerDetailDto; import cn.fw.valhalla.sdk.api.CustomerApiService; import cn.fw.valhalla.sdk.param.ChangeAdviserReq; +import cn.fw.valhalla.sdk.param.ChangePlateNoReq; import cn.fw.valhalla.sdk.param.CustomerParams; import cn.fw.valhalla.sdk.result.CustomerContactDto; import cn.fw.valhalla.sdk.result.CustomerInfoDto; @@ -11,6 +12,7 @@ import cn.fw.valhalla.sdk.result.ReceptionResultDto; import cn.fw.valhalla.service.bus.cust.ContactBizService; import cn.fw.valhalla.service.bus.cust.CustomerBizService; import cn.fw.valhalla.service.bus.cust.CustomerChangeBizService; +import cn.fw.valhalla.service.bus.cust.PickUpCustomerService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; @@ -42,15 +44,18 @@ public class CustomerApiServiceImpl implements CustomerApiService { private final CustomerBizService customerBiz; private final CustomerChangeBizService changeBizService; private final ContactBizService contactBizService; + private final PickUpCustomerService pickUpCustomerService; @Autowired CustomerApiServiceImpl(final CustomerBizService customerBiz, final CustomerChangeBizService changeBizService, - final ContactBizService contactBizService) { + final ContactBizService contactBizService, + final PickUpCustomerService pickUpCustomerService) { this.customerBiz = customerBiz; this.changeBizService = changeBizService; this.contactBizService = contactBizService; + this.pickUpCustomerService = pickUpCustomerService; } @PostMapping("/save") @@ -174,7 +179,7 @@ public class CustomerApiServiceImpl implements CustomerApiService { @PostMapping("/change/adviser") @Override - public Message changeAdviser(@RequestBody final ChangeAdviserReq changeAdviserReq) { + public Message changeAdviser(@Valid @RequestBody final ChangeAdviserReq changeAdviserReq) { final String msg = "修改保有客专属顾问[changeAdviser]"; log.info("{}: param:{}", msg, changeAdviserReq); try { @@ -255,4 +260,18 @@ public class CustomerApiServiceImpl implements CustomerApiService { return failureWithMessage("查询联系人信息失败"); } } + + @Override + @PostMapping("/updatePlateNo") + public Message updatePlateNo(@Valid @RequestBody ChangePlateNoReq changePlateNoReq) { + final String msg = "通过vin修改车牌号[updatePlateNo]"; + log.info("{}: param:[{}]", msg, changePlateNoReq); + try { + return success(pickUpCustomerService.fixPlateNo(changePlateNoReq.getFrameNo(), changePlateNoReq.getPlateNo(), changePlateNoReq.getGroupId()), + data -> log.info("{}:data[{}]", msg, data)); + } catch (Exception ex) { + handleException(ex, e -> log.error("{}失败: param:[{}]", msg, changePlateNoReq, e)); + return failureWithMessage("通过vin修改车牌号失败"); + } + } } diff --git a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/CommonController.java b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/CommonController.java index f5fda71..ff55ee6 100644 --- a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/CommonController.java +++ b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/CommonController.java @@ -56,15 +56,14 @@ public class CommonController { @GetMapping("/staff/list") @IgnoreAuth - public Message> list(@NotNull(message = "服务站ID不能为空") final Long shopId, - @NotNull(message = "跟进类型不能为空") final Integer type) { - final String msg = "查询跟进人员[app/common/staff/list]"; + public Message> list(@NotNull(message = "服务站ID不能为空") final Long shopId) { + final String msg = "查询人员[app/common/staff/list]"; try { - log.info("{}: param[shopId: {} type: {}]", msg, shopId, type); - List list = commonService.getUsers(shopId, type); + log.info("{}: param[shopId: {}]", msg, shopId); + List list = commonService.getUsers(shopId); return success(list, data -> log.info("{}", data)); } catch (Exception ex) { - handleException(ex, e -> log.error("{}失败:param[shopId: {} type: {}]", msg, shopId, type, e)); + handleException(ex, e -> log.error("{}失败:param[shopId: {}]", msg, shopId, e)); return failureWithMessage(SAVE_FAILURE); } } diff --git a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java index c1d691e..feeaee1 100644 --- a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java +++ b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/app/PoolController.java @@ -9,7 +9,9 @@ import cn.fw.security.auth.client.annotation.IgnoreAuth; import cn.fw.security.auth.client.enums.AuthType; import cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO; import cn.fw.valhalla.domain.query.FollowPoolQueryVO; +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery; import cn.fw.valhalla.domain.query.StammkundePoolQueryVO; +import cn.fw.valhalla.domain.vo.SecretReportHistoryVO; import cn.fw.valhalla.domain.vo.follow.FollowDetailVO; import cn.fw.valhalla.domain.vo.pool.*; import cn.fw.valhalla.service.bus.follow.FollowBizService; @@ -161,4 +163,19 @@ public class PoolController { return failureWithMessage(QUERY_FAILURE); } } + + @GetMapping("/secret/report/list") + @IgnoreAuth + public Message> reportList(@CurrentUser LoginAuthBean currentUser, final SecretReportHistoryQuery queryVO) { + final String msg = "查询智能通话记录池列表[pool/clue/list]"; + try { + log.info("{}: param[{}]", msg, queryVO); + queryVO.setGroupId(currentUser.getGroupId()); + AppPage page = poolBizService.secretReportList(queryVO); + return success(page, data -> log.info("dataSize: {}", CollectionUtils.isEmpty(data.getData()) ? 0 : data.getData().size())); + } catch (Exception ex) { + handleException(ex, e -> log.error("{}失败:param[{}]", msg, queryVO.getTaskType(), e)); + return failureWithMessage(QUERY_FAILURE); + } + } } diff --git a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java index 7dab208..68ad79c 100644 --- a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java +++ b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/CallReportDealTask.java @@ -69,7 +69,7 @@ public class CallReportDealTask { /** * 处理通话记录 */ - @Scheduled(initialDelay = 1000 * 5, fixedRate = 1000 * 5) + @Scheduled(initialDelay = 1000 * 5, fixedRate = 1000 * 15) public void dealCallReport() { List failList = new ArrayList<>(); String callStr; @@ -78,20 +78,21 @@ public class CallReportDealTask { if (Objects.isNull(dto)) { continue; } - final String mobileNo = dto.getPeerNo(); + final String staffMobile = dto.getStaffMobile(); + final String peerMobile = dto.getPeerNo(); final Long groupId = dto.getGroupId(); final Long staffId = dto.getStaffId(); try { boolean isValid = Objects.nonNull(staffId) && Objects.nonNull(groupId); if (!isValid) { - StaffInfoDTO info = ehrRpcService.queryStaffInfoByMobile(mobileNo); - BV.notNull(info, () -> "员工信息获取失败"); + StaffInfoDTO info = ehrRpcService.queryStaffInfoByMobile(staffMobile); + BV.notNull(info, () -> String.format("[%s]员工信息获取失败", staffMobile)); assert info != null; dto.setStaffId(info.getId()); dto.setGroupId(info.getGroupId()); } - followBizService.readCallReport(dto, true, queryAccidentCar(mobileNo, groupId)); - followBizService.readCallReport(dto, false, queryCustomerIds(mobileNo, groupId)); + followBizService.readCallReport(dto, true, queryAccidentCar(peerMobile, groupId)); + followBizService.readCallReport(dto, false, queryCustomerIds(peerMobile, groupId)); } catch (Exception e) { if (StringUtils.isValid(callStr)) { failList.add(callStr); diff --git a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/RoleChangeTask.java b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/RoleChangeTask.java index d614a2a..adca4c9 100644 --- a/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/RoleChangeTask.java +++ b/fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/RoleChangeTask.java @@ -1,7 +1,11 @@ package cn.fw.valhalla.controller.task; +import cn.fw.valhalla.common.constant.RoleCode; import cn.fw.valhalla.common.utils.StringUtils; import cn.fw.valhalla.domain.db.LeaveNeedDo; +import cn.fw.valhalla.domain.dto.RoleChangeDTO; +import cn.fw.valhalla.domain.enums.LeaveReasonEnum; +import cn.fw.valhalla.domain.enums.LeaveTodoTypeEnum; import cn.fw.valhalla.service.bus.LeaveNeedDoBizService; import com.alibaba.fastjson.JSONObject; import lombok.Getter; @@ -15,6 +19,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Objects; @@ -31,9 +36,9 @@ public class RoleChangeTask { private final LeaveNeedDoBizService leaveNeedDoBizService; private final StringRedisTemplate redisTemplate; - @Value("${spring.cache.custom.global-prefix}:mq:role:change") + @Value("${spring.cache.custom.global-prefix}:mq:role") @Getter - private String roleChangeKey; + private String keyPrefix; @Autowired public RoleChangeTask(final LeaveNeedDoBizService leaveNeedDoBizService, @@ -44,28 +49,71 @@ public class RoleChangeTask { /** - * 处理员工角色变动 + * 服务顾问角色变动 */ @Scheduled(initialDelay = 1000 * 30, fixedRate = 1000 * 60 * 60) - public void dealData() { + public void dealFwgwData() { List failList = new ArrayList<>(); String jsonStr; - while ((jsonStr = redisTemplate.opsForList().leftPop(getRoleChangeKey())) != null) { - LeaveNeedDo leaveNeedDo = JSONObject.parseObject(jsonStr, LeaveNeedDo.class); - if (Objects.isNull(leaveNeedDo)) { + while ((jsonStr = redisTemplate.opsForList().leftPop(getRedisKey(RoleCode.FWGW))) != null) { + RoleChangeDTO roleChangeDTO = JSONObject.parseObject(jsonStr, RoleChangeDTO.class); + if (Objects.isNull(roleChangeDTO)) { continue; } try { - leaveNeedDoBizService.add(leaveNeedDo); + leaveNeedDoBizService.add(createDb(roleChangeDTO.getUserId(), roleChangeDTO.getShopId(), roleChangeDTO.getUserName())); } catch (Exception e) { if (StringUtils.isValid(jsonStr)) { failList.add(jsonStr); } - log.error("处理员工角色变动失败", e); + log.error("处理服务接待角色变动失败", e); } } if (!CollectionUtils.isEmpty(failList)) { - redisTemplate.opsForList().rightPushAll(getRoleChangeKey(), failList); + redisTemplate.opsForList().rightPushAll(getRedisKey(RoleCode.FWGW), failList); } } + + /** + * 续保角色 + */ + @Scheduled(initialDelay = 1000 * 30, fixedRate = 1000 * 60 * 60) + public void dealXbData() { + List failList = new ArrayList<>(); + String jsonStr; + while ((jsonStr = redisTemplate.opsForList().leftPop(getRedisKey(RoleCode.XBGJ))) != null) { + RoleChangeDTO roleChangeDTO = JSONObject.parseObject(jsonStr, RoleChangeDTO.class); + if (Objects.isNull(roleChangeDTO)) { + continue; + } + try { + leaveNeedDoBizService.xbgjChanged(roleChangeDTO); + } catch (Exception e) { + if (StringUtils.isValid(jsonStr)) { + failList.add(jsonStr); + } + log.error("处理续保跟进角色变动失败", e); + } + } + if (!CollectionUtils.isEmpty(failList)) { + redisTemplate.opsForList().rightPushAll(getRedisKey(RoleCode.XBGJ), failList); + } + } + + private String getRedisKey(final String roleCode) { + return String.format("%s:change:%s", getKeyPrefix(), roleCode); + } + + private LeaveNeedDo createDb(Long userId, Long shopId, String userName) { + LeaveNeedDo leaveNeedDo = new LeaveNeedDo(); + leaveNeedDo.setDone(Boolean.FALSE); + leaveNeedDo.setEffectiveTime(new Date()); + leaveNeedDo.setReason(LeaveReasonEnum.CHANGE); + leaveNeedDo.setType(LeaveTodoTypeEnum.CUSTOMER); + leaveNeedDo.setShopId(shopId); + leaveNeedDo.setUserId(userId); + leaveNeedDo.setUserName(userName); + leaveNeedDo.setCreateTime(new Date()); + return leaveNeedDo; + } } diff --git a/fw-valhalla-server/src/test/java/cn/fw/valhalla/ValhallaAppTests.java b/fw-valhalla-server/src/test/java/cn/fw/valhalla/ValhallaAppTests.java index 114550a..639c6e0 100644 --- a/fw-valhalla-server/src/test/java/cn/fw/valhalla/ValhallaAppTests.java +++ b/fw-valhalla-server/src/test/java/cn/fw/valhalla/ValhallaAppTests.java @@ -1,5 +1,6 @@ package cn.fw.valhalla; +import cn.fw.common.util.ValidationUtils; import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -35,4 +36,9 @@ class ValhallaAppTests { .andDo(MockMvcResultHandlers.print()); } + @Test + public void phoneTest() { + String phone ="+8619142820251"; + System.out.println(ValidationUtils.checkMobile(phone)); + } } diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java index b15205f..be15527 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/CallReportConsumer.java @@ -1,8 +1,10 @@ package cn.fw.valhalla.component; +import cn.fw.pstn.sdk.enums.DialTypeEnum; import cn.fw.pstn.sdk.mq.CallReport; import cn.fw.valhalla.common.utils.StringUtils; import cn.fw.valhalla.domain.dto.CallReportDTO; +import cn.fw.valhalla.domain.enums.CallTypeEnum; import cn.fw.valhalla.rpc.ehr.EhrRpcService; import cn.fw.valhalla.rpc.ehr.dto.StaffInfoDTO; import com.alibaba.fastjson.JSON; @@ -52,6 +54,10 @@ public class CallReportConsumer implements RocketMQListener { } CallReportDTO dto = new CallReportDTO(); BeanUtils.copyProperties(t, dto); + dto.setDialType(CallTypeEnum.CALL); + if (DialTypeEnum.P_CALL.equals(t.getCallType())) { + dto.setDialType(CallTypeEnum.P_CALL); + } String staffMobile = t.getStaffMobile(); if (StringUtils.isEmpty(staffMobile)) { return; @@ -59,6 +65,7 @@ public class CallReportConsumer implements RocketMQListener { StaffInfoDTO info = ehrRpcService.queryStaffInfoByMobile(staffMobile); if (Objects.nonNull(info)) { dto.setStaffId(info.getId()); + dto.setStaffName(info.getName()); dto.setGroupId(info.getGroupId()); } redisTemplate.opsForList().rightPush(getCallReportKey(), JSONObject.toJSONString(dto)); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/RoleChangeConsumer.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/RoleChangeConsumer.java index 3514ca3..7e812ee 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/RoleChangeConsumer.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/component/RoleChangeConsumer.java @@ -4,6 +4,7 @@ import cn.fw.erp.sdk.api.enums.OperateTypeEnum; import cn.fw.erp.sdk.api.mq.RoleChangeEvent; import cn.fw.valhalla.common.constant.RoleCode; import cn.fw.valhalla.domain.db.LeaveNeedDo; +import cn.fw.valhalla.domain.dto.RoleChangeDTO; import cn.fw.valhalla.domain.enums.LeaveReasonEnum; import cn.fw.valhalla.domain.enums.LeaveTodoTypeEnum; import com.alibaba.fastjson.JSON; @@ -32,9 +33,9 @@ import java.util.Objects; public class RoleChangeConsumer implements RocketMQListener { private final StringRedisTemplate redisTemplate; - @Value("${spring.cache.custom.global-prefix}:mq:role:change") + @Value("${spring.cache.custom.global-prefix}:mq:role") @Getter - private String roleChangeKey; + private String keyPrefix; @Autowired public RoleChangeConsumer(final StringRedisTemplate redisTemplate) { @@ -48,28 +49,21 @@ public class RoleChangeConsumer implements RocketMQListener { if (Objects.isNull(t)) { return; } - if (OperateTypeEnum.REMOVE.getValue().equals(t.getType()) && RoleCode.FWGW.equalsIgnoreCase(t.getRoleCode())) { - Long shopId = t.getRangeValue(); - Long userId = t.getUserId(); - String userName = t.getUserName(); - LeaveNeedDo leaveNeedDo = createDb(userId, shopId, userName); - redisTemplate.boundListOps(getRoleChangeKey()).rightPush(JSONObject.toJSONString(leaveNeedDo)); + if (OperateTypeEnum.BLOCK.getValue().equals(t.getType()) && RoleCode.FWGW.equalsIgnoreCase(t.getRoleCode())) { + String jsonString = JSONObject.toJSONString(new RoleChangeDTO(t.getRangeValue(), t.getUserId(), t.getUserName())); + redisTemplate.boundListOps(getRedisKey(RoleCode.FWGW)).rightPush(jsonString); + } + + if (OperateTypeEnum.BLOCK.getValue().equals(t.getType()) && RoleCode.XBGJ.equalsIgnoreCase(t.getRoleCode())) { + String jsonString = JSONObject.toJSONString(new RoleChangeDTO(t.getRangeValue(), t.getUserId(), t.getUserName())); + redisTemplate.boundListOps(getRedisKey(RoleCode.XBGJ)).rightPush(jsonString); } } catch (Exception ex) { log.error("消费角色变动mq失败,原因:{}", JSON.toJSONString(ex)); } } - private LeaveNeedDo createDb(Long userId, Long shopId, String userName) { - LeaveNeedDo leaveNeedDo = new LeaveNeedDo(); - leaveNeedDo.setDone(Boolean.FALSE); - leaveNeedDo.setEffectiveTime(new Date()); - leaveNeedDo.setReason(LeaveReasonEnum.CHANGE); - leaveNeedDo.setType(LeaveTodoTypeEnum.CUSTOMER); - leaveNeedDo.setShopId(shopId); - leaveNeedDo.setUserId(userId); - leaveNeedDo.setUserName(userName); - leaveNeedDo.setCreateTime(new Date()); - return leaveNeedDo; + private String getRedisKey(final String roleCode) { + return String.format("%s:change:%s", getKeyPrefix(), roleCode); } } diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CommonService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CommonService.java index d9e6cd9..88c6414 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CommonService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CommonService.java @@ -1,27 +1,32 @@ package cn.fw.valhalla.service.bus; +import cn.fw.common.util.ValidationUtils; import cn.fw.valhalla.common.constant.RoleCode; import cn.fw.valhalla.domain.db.customer.AccidentPool; import cn.fw.valhalla.domain.db.customer.Customer; import cn.fw.valhalla.domain.db.customer.CustomerBaseInfo; +import cn.fw.valhalla.domain.db.pool.StammkundePool; import cn.fw.valhalla.domain.enums.FollowTypeEnum; +import cn.fw.valhalla.domain.enums.StammkundeStatusEnum; import cn.fw.valhalla.domain.vo.PostUserVO; import cn.fw.valhalla.rpc.ehr.EhrRpcService; import cn.fw.valhalla.rpc.ehr.dto.StaffInfoDTO; import cn.fw.valhalla.rpc.erp.UserService; import cn.fw.valhalla.rpc.erp.dto.PostUserDTO; -import cn.fw.valhalla.rpc.order.OrderRpcService; import cn.fw.valhalla.rpc.pstn.PstnService; import cn.fw.valhalla.service.bus.cust.CustomerChangeBizService; import cn.fw.valhalla.service.data.AccidentPoolService; import cn.fw.valhalla.service.data.CustomerBaseInfoService; import cn.fw.valhalla.service.data.CustomerService; +import cn.fw.valhalla.service.data.StammkundePoolService; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import static cn.fw.common.businessvalidator.Validator.BV; @@ -38,18 +43,33 @@ public class CommonService { private final UserService userService; private final CustomerService customerService; private final CustomerBaseInfoService customerBaseInfoService; - private final OrderRpcService orderRpcService; + private final StammkundePoolService stammkundePoolService; private final PstnService pstnService; private final EhrRpcService ehrRpcService; private final AccidentPoolService accidentPoolService; private final CustomerChangeBizService customerChangeBizService; - public List getUsers(final Long shopId, final Integer type) { - FollowTypeEnum typeEnum = FollowTypeEnum.ofValue(type); - BV.notNull(typeEnum, () -> "跟进类型错误"); - List userByRole = userService.getUserByRole(shopId, getRoleCode(typeEnum)); - return userByRole.stream().map(user -> new PostUserVO(user.getUserId(), user.getUserName())).collect(Collectors.toList()); + public List getUsers(final Long shopId) { + List list = new ArrayList<>(); + List userByRole = userService.getUserByRole(shopId, RoleCode.FWGW); + if (CollectionUtils.isEmpty(userByRole)) { + return list; + } + + for (PostUserDTO userDTO : userByRole) { + PostUserVO vo = new PostUserVO(userDTO.getUserId(), userDTO.getUserName(), 0); + int count = stammkundePoolService.count(Wrappers.lambdaQuery() + .eq(StammkundePool::getAdviserId, userDTO.getUserId()) + .eq(StammkundePool::getShopId, shopId) + .eq(StammkundePool::getPoolStatus, StammkundeStatusEnum.KUNDE) + .eq(StammkundePool::getAktiv, Boolean.TRUE) + .isNull(StammkundePool::getRejectTime) + ); + vo.setCurQuantity(count); + list.add(vo); + } + return list; } public void rollBack(String vin, Long groupId) { @@ -77,6 +97,9 @@ public class CommonService { AccidentPool accidentPool = accidentPoolService.getById(cusId); BV.notNull(accidentPool, () -> "用户不存在"); becallNo = accidentPool.getReportMobile(); + if (!ValidationUtils.checkMobile(becallNo)) { + return becallNo; + } } else { Customer customer = customerService.queryByIdWithInvalid(cusId); BV.notNull(customer, () -> "用户不存在"); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/LeaveNeedDoBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/LeaveNeedDoBizService.java index d595c08..6d27c88 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/LeaveNeedDoBizService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/LeaveNeedDoBizService.java @@ -16,6 +16,7 @@ import cn.fw.valhalla.domain.db.follow.FollowTask; import cn.fw.valhalla.domain.db.pool.CustomerCluePool; import cn.fw.valhalla.domain.db.pool.StammkundePool; import cn.fw.valhalla.domain.dto.LeaveAllocationDTO; +import cn.fw.valhalla.domain.dto.RoleChangeDTO; import cn.fw.valhalla.domain.dto.StammkundeDto; import cn.fw.valhalla.domain.enums.*; import cn.fw.valhalla.domain.query.LeaveQueryVO; @@ -67,6 +68,7 @@ public class LeaveNeedDoBizService { private final OopService oopService; private final FollowBizService followBizService; private final FollowTaskService followTaskService; + private final FollowRecordService followRecordService; private final DistributedLocker distributedLocker; private final ImSendMessage imSendMessage; private final TodoRpcService todoRpcService; @@ -175,26 +177,56 @@ public class LeaveNeedDoBizService { } } + + @Transactional(rollbackFor = Exception.class) + public void xbgjChanged(RoleChangeDTO dto) { + final Long userId = dto.getUserId(); + final Long shopId = dto.getShopId(); + List statusList = Arrays.asList(ClueStatusEnum.WAITING, ClueStatusEnum.ONGOING); + List list = customerCluePoolService.list(Wrappers.lambdaQuery() + .in(CustomerCluePool::getClueStatus, statusList) + .eq(CustomerCluePool::getOriginalShopId, shopId) + .eq(CustomerCluePool::getClueType, FollowTypeEnum.IR) + .eq(CustomerCluePool::getOriginalUserId, userId) + ); + if (CollectionUtils.isEmpty(list)) { + return; + } + List userList = userService.getUserByRole(shopId, RoleCode.XBGJ); + BV.isNotEmpty(userList, () -> "更换跟进人员失败:没有更多续保跟进员"); + Collections.shuffle(userList); + PostUserDTO userDTO = userList.stream().filter(u -> !u.getUserId().equals(userId)).findAny().orElse(null); + BV.notNull(userDTO, () -> "更换跟进人员失败:没有更多续保跟进员"); + + for (CustomerCluePool clue : list) { + if (ClueStatusEnum.WAITING.equals(clue.getClueStatus())) { + clue.setOriginalUserId(userDTO.getUserId()); + clue.setOriginalUserName(userDTO.getUserName()); + clue.setOriginalShopId(shopId); + Optional.ofNullable(oopService.shop(shopId)).ifPresent(shop -> clue.setOriginalShopName(shop.getShortName())); + continue; + } + dealTask(clue, userDTO.getUserId(), shopId); + } + + customerCluePoolService.updateBatchById(list); + } + private void prepareAllocation(LeaveAllocationDTO dto) { - AllocationTypeEnum typeEnum = AllocationTypeEnum.ofValue(dto.getAllocationType()); - BV.notNull(typeEnum, () -> "分配方式不正确,请重试"); - dto.setType(typeEnum); LeaveNeedDo needDo = leaveNeedDoService.queryProcessableById(dto.getId()); BV.notNull(needDo, () -> "该条记录已处理或不存在,请刷新后重试"); - dto.setAdviserId(needDo.getUserId()); - if (AllocationTypeEnum.ONE.equals(typeEnum)) { - BV.notNull(dto.getUserId(), () -> "指定人员不能为空"); - List dataRange = userService.getUserRoleDataRange(dto.getUserId(), RoleCode.FWGW); + + List ruleList = dto.getRuleList(); + BV.notNull(ruleList, () -> "分配规则不能为空"); + + for (LeaveAllocationDTO.Allocation rule : ruleList) { + List dataRange = userService.getUserRoleDataRange(rule.getUserId(), RoleCode.FWGW); List shopIdList = dataRange.stream().map(UserRoleDataRangeDTO::getRangeValue).collect(Collectors.toList()); - BV.isNotEmpty(shopIdList, () -> "指定人员非服务顾问角色,请核对"); + BV.isNotEmpty(shopIdList, () -> String.format("[%s]无服务接待角色,请核对", rule.getUserName())); Long shopId = shopIdList.get(0); - BV.isTrue(needDo.getShopId().equals(shopId), () -> "指定人员所属门店与档案归属门店不符"); - dto.setShopId(shopId); - } - - if (AllocationTypeEnum.ALL.equals(dto.getType())) { - dto.setShopId(needDo.getShopId()); + BV.isTrue(needDo.getShopId().equals(shopId), () -> String.format("[%s]所属门店与离职人员门店不符", rule.getUserName())); + rule.setShopId(shopId); } } @@ -209,63 +241,35 @@ public class LeaveNeedDoBizService { if (CollectionUtils.isEmpty(customerList)) { return null; } - if (AllocationTypeEnum.ONE.equals(dto.getType())) { - allocation(key, customerList, dto); - } - if (AllocationTypeEnum.ALL.equals(dto.getType())) { - allocation(key, customerList, dto.getShopId()); - } - return customerList; - } + List ruleList = dto.getRuleList(); - /** - * 分配给指定人员 - * - * @param list - * @param dto - */ - private void allocation(String key, List list, LeaveAllocationDTO dto) { - List spl = new ArrayList<>(list.size()); - final String userName = Optional.ofNullable(userService.user(dto.getUserId())).map(UserInfoDTO::getUserName).orElse(""); - for (Customer customer : list) { - customer.setShopId(dto.getShopId()); - customer.setAdviserId(dto.getUserId()); - spl.add(createPool(customer, userName)); - rejectPool(customer.getId(), dto.getShopId(), userName, dto.getUserId(), customer.getGroupId()); - } - customerService.updateBatchById(list); - stammkundePoolService.saveBatch(spl); - setToCache(key, new UserInfo(dto.getUserId(), "", list.size())); - } + final List list = new ArrayList<>(); + final List spl = new ArrayList<>(); + final LinkedList queue = new LinkedList<>(); - /** - * 门店内平均分配 - * - * @param list - * @param shopId - */ - private void allocation(String key, List list, Long shopId) { - List users = userService.getUserByRole(shopId, RoleCode.FWGW); - BV.isNotEmpty(users, () -> "该门店没有服务顾问,请检查配置是否正确"); - List spl = new ArrayList<>(list.size()); - LinkedList queue = new LinkedList<>(); - for (PostUserDTO user : users) { - queue.offer(new UserInfo(user.getUserId(), user.getUserName())); - } - for (Customer customer : list) { - UserInfo info = queue.poll(); - customer.setShopId(shopId); - customer.setAdviserId(Objects.requireNonNull(info, "服务顾问信息获取异常,请重试").getUserId()); - info.setCount(info.getCount() + 1); - rejectPool(customer.getId(), shopId, info.getUserName(), info.getUserId(), customer.getGroupId()); - spl.add(createPool(customer, info.getUserName())); - queue.offer(info); + for (LeaveAllocationDTO.Allocation rule : ruleList) { + int size = customerList.size(); + List subList = customerList.subList(0, rule.getNum() > size ? size : rule.getNum()); + if (CollectionUtils.isEmpty(subList)) { + continue; + } + for (Customer customer : subList) { + customer.setShopId(rule.getShopId()); + customer.setAdviserId(rule.getUserId()); + rejectPool(customer.getId(), rule.getShopId(), rule.getUserName(), rule.getUserId(), customer.getGroupId()); + spl.add(createPool(customer, rule.getUserName())); + list.add(customer); + } + queue.add(new UserInfo(rule.getUserId(), rule.getUserName(), subList.size())); + subList.clear(); } customerService.updateBatchById(list); stammkundePoolService.saveBatch(spl); setToCache(key, queue); + return list; } + /** * 完成分配的后续处理逻辑 * @@ -310,24 +314,27 @@ public class LeaveNeedDoBizService { customerCluePoolService.updateBatchById(list); } - private void dealTask(CustomerCluePool clue, Long adviserId, Long shopId) { - if (Boolean.FALSE.equals(clue.getRedistribution())) { - clue.setRedistribution(Boolean.TRUE); - } + private void dealTask(CustomerCluePool clue, Long userId, Long shopId) { FollowTask task = followTaskService.queryOngoingTaskByClueId(clue.getId()); if (Objects.isNull(task)) { return; } - if (Boolean.TRUE.equals(task.getRedistribution())) { - task.setFollowUser(adviserId); - task.setFollowShop(shopId); - followTaskService.updateById(task); - return; - } + UserInfoDTO user = userService.user(userId); + String userName = Objects.nonNull(user) ? user.getUserName() : ""; task.setCloseTime(new Date()); task.setState(TaskStateEnum.DEFEAT); task.setReason(TaskDefeatTypeEnum.D); followTaskService.updateById(task); + followRecordService.removeByTaskId(task.getId()); + + if (Boolean.TRUE.equals(task.getRedistribution())) { + clue.setCloseTime(new Date()); + clue.setClueStatus(ClueStatusEnum.FAILURE); + return; + } else { + clue.setRedistribution(Boolean.TRUE); + } + FollowTask nTask = new FollowTask(); nTask.setClueId(clue.getId()); nTask.setCustomerId(clue.getRefererId()); @@ -336,13 +343,15 @@ public class LeaveNeedDoBizService { nTask.setBeginTime(new Date()); nTask.setRedistribution(Boolean.TRUE); nTask.setDeadline(clue.getDeadline()); - nTask.setFollowUser(adviserId); + nTask.setFollowUser(userId); + task.setFollowUserName(userName); nTask.setFollowShop(shopId); nTask.setGroupId(clue.getGroupId()); followTaskService.save(nTask); followBizService.startTask(nTask); } + private void finish(LoginAuthBean user, Long leaveId, String key) { leaveNeedDoService.dealById(leaveId); List list = getAllFromCache(key); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/AbstractCustomerService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/AbstractCustomerService.java index 32c8e96..6cf57dd 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/AbstractCustomerService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/AbstractCustomerService.java @@ -131,6 +131,7 @@ public abstract class AbstractCustomerService { dto.setInsuranceExpires(customer.getInsuranceExpires()); dto.setArrivalTime(customer.getArrivalTime()); dto.setAdviserId(customer.getAdviserId()); + dto.setArrivalCount(customer.getArrivalCount()); UserInfoDTO user = userService.user(customer.getAdviserId()); if (Objects.nonNull(user)) { dto.setAdviserName(user.getUserName()); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java index 73c0fb5..186610a 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java @@ -369,9 +369,6 @@ public class CustomerBizService extends AbstractCustomerService { if (Objects.isNull(detailDto)) { return; } - if (publicPoolService.queryByPlate(detailDto.getPlateNo(), detailDto.getGroupId()).isPresent()) { - return; - } List typeList = Arrays.asList(FollowTypeEnum.AC, FollowTypeEnum.IR); HashSet set = new HashSet<>(typeList); if (set.contains(task.getType())) { @@ -383,6 +380,9 @@ public class CustomerBizService extends AbstractCustomerService { if (FollowTypeEnum.RM.equals(task.getType())) { type = PublicPoolTypeEnum.RM; } + if (publicPoolService.queryByPlate(detailDto.getPlateNo(), detailDto.getGroupId()).isPresent()) { + return; + } PublicPool publicPool = createPublicPool(detailDto, type, "系统判定"); boolean updated = customerService.update(Wrappers.lambdaUpdate() .set(Customer::getAdviserId, null) diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/PickUpCustomerService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/PickUpCustomerService.java index 05abaed..7a85c29 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/PickUpCustomerService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/PickUpCustomerService.java @@ -74,6 +74,22 @@ public class PickUpCustomerService extends AbstractCustomerService { } /** + * 修改车牌号 + * + * @param frameNo + * @param plateNo + * @param groupId + * @return + */ + @Transactional(rollbackFor = Exception.class) + public Boolean fixPlateNo(String frameNo, String plateNo, Long groupId) { + Customer customer = customerService.queryByFrameNo(frameNo, groupId); + BV.notNull(customer, () -> "车架号有误"); + customer.setPlateNo(plateNo); + return customerService.updateById(customer); + } + + /** * 根据vin查询档案 * * @param currentUser diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java index 9c53b20..f93ff69 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/FollowBizService.java @@ -6,7 +6,9 @@ import cn.fw.common.web.auth.LoginAuthBean; import cn.fw.valhalla.common.utils.DateUtil; import cn.fw.valhalla.domain.db.ApproveRecord; import cn.fw.valhalla.domain.db.OriginalData; +import cn.fw.valhalla.domain.db.SecretReportHistory; import cn.fw.valhalla.domain.db.follow.FollowRecord; +import cn.fw.valhalla.domain.db.follow.FollowRecordLog; import cn.fw.valhalla.domain.db.follow.FollowTask; import cn.fw.valhalla.domain.db.pool.CustomerCluePool; import cn.fw.valhalla.domain.dto.CallReportDTO; @@ -23,10 +25,7 @@ import cn.fw.valhalla.rpc.flow.FlowApproveRpc; import cn.fw.valhalla.rpc.flow.dto.FlowDto; import cn.fw.valhalla.sdk.enums.DataTypeEnum; import cn.fw.valhalla.service.bus.follow.strategy.FollowStrategy; -import cn.fw.valhalla.service.data.ApproveRecordService; -import cn.fw.valhalla.service.data.CustomerCluePoolService; -import cn.fw.valhalla.service.data.FollowRecordService; -import cn.fw.valhalla.service.data.FollowTaskService; +import cn.fw.valhalla.service.data.*; import cn.fw.valhalla.service.event.TaskCancelEvent; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.Getter; @@ -67,6 +66,8 @@ public class FollowBizService { private final UserService userService; private final DistributedLocker distributedLocker; private final CustomerCluePoolService customerCluePoolService; + private final SecretReportHistoryService secretReportHistoryService; + private final FollowRecordLogService followRecordLogService; @Value("${follow.flowNo}") @Getter @@ -84,7 +85,9 @@ public class FollowBizService { final FollowRecordService followRecordService, final UserService userService, final DistributedLocker distributedLocker, - final CustomerCluePoolService customerCluePoolService) { + final CustomerCluePoolService customerCluePoolService, + final SecretReportHistoryService secretReportHistoryService, + final FollowRecordLogService followRecordLogService) { this.followMap = followStrategyList.stream().collect(Collectors.toMap(FollowStrategy::getFollowType, v -> v)); this.flowApproveRpc = flowApproveRpc; this.approveRecordService = approveRecordService; @@ -93,6 +96,8 @@ public class FollowBizService { this.userService = userService; this.distributedLocker = distributedLocker; this.customerCluePoolService = customerCluePoolService; + this.secretReportHistoryService = secretReportHistoryService; + this.followRecordLogService = followRecordLogService; } /** @@ -479,6 +484,10 @@ public class FollowBizService { } final Long groupId = dto.getGroupId(); final Long staffId = dto.getStaffId(); + final Long talkTime = dto.getTalkTime(); + if (Objects.isNull(talkTime) || talkTime <= 0) { + return; + } if (accidentCar) { CustomerCluePool cluePool = customerCluePoolService.getOne(Wrappers.lambdaQuery() .eq(CustomerCluePool::getRefererId, idArr[0]) @@ -489,7 +498,7 @@ public class FollowBizService { .last(" limit 1") ); if (Objects.nonNull(cluePool)) { - completeRecord(cluePool.getId(), staffId, dto.getCallId()); + completeRecord(dto, cluePool.getId(), staffId, dto.getCallId()); } } else { List list = customerCluePoolService.list(Wrappers.lambdaQuery() @@ -498,7 +507,7 @@ public class FollowBizService { .in(CustomerCluePool::getRefererId, Arrays.asList(idArr)) ); if (!CollectionUtils.isEmpty(list)) { - list.forEach(cluePool -> completeRecord(cluePool.getId(), staffId, dto.getCallId())); + list.forEach(cluePool -> completeRecord(dto, cluePool.getId(), staffId, dto.getCallId())); } } } @@ -540,7 +549,7 @@ public class FollowBizService { ) > 0; } - private void completeRecord(final Long clueId, final Long staffId, final String callId) { + private void completeRecord(CallReportDTO reportDTO, final Long clueId, final Long staffId, final String callId) { FollowTask followTask = followTaskService.queryOngoingTaskByClueId(clueId); if (Objects.isNull(followTask)) { return; @@ -560,6 +569,7 @@ public class FollowBizService { FollowStrategy strategy = followMap.get(followType); Assert.notNull(strategy, "strategy cannot be null"); + List reportHistoryList = new ArrayList<>(); for (FollowRecord record : list) { FollowAttachmentDTO dto = new FollowAttachmentDTO(); @@ -569,6 +579,31 @@ public class FollowBizService { dto.setFeedbackType(FollowTypeEnum.AC.equals(followType) ? FeedbackTypeEnum.OTHER.getValue() : null); dto.setAttType(AttTypeEnum.SMART_PHONE.getValue()); strategy.uploadAtt(dto, staffId); + reportHistoryList.add(createHistory(reportDTO, record, followType)); } + secretReportHistoryService.saveBatch(reportHistoryList); + } + + + private SecretReportHistory createHistory(CallReportDTO reportDTO, FollowRecord record, FollowTypeEnum followTypeEnum) { + SecretReportHistory history = new SecretReportHistory(); + history.setTaskId(record.getTaskId()); + history.setTaskType(followTypeEnum); + history.setFollowRecordId(record.getId()); + history.setCallId(reportDTO.getCallId()); + history.setStaffId(reportDTO.getStaffId()); + history.setStaffName(reportDTO.getStaffName()); + history.setCustomerId(record.getCustomerId()); + history.setCallType(reportDTO.getDialType()); + history.setCallTime(reportDTO.getCallTime()); + history.setCallDuration(reportDTO.getTalkTime()); + history.setShopId(record.getShopId()); + history.setGroupId(record.getGroupId()); + int count = followRecordLogService.count(Wrappers.lambdaQuery() + .eq(FollowRecordLog::getTaskId, record.getTaskId()) + .eq(FollowRecordLog::getAttType, AttTypeEnum.SMART_PHONE) + ); + history.setFirstCall(count <= 0); + return history; } } diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java index ed753f1..69062c1 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java @@ -8,13 +8,12 @@ import cn.fw.valhalla.domain.db.customer.AffiliationRecord; import cn.fw.valhalla.domain.db.pool.PublicPool; import cn.fw.valhalla.domain.dto.CustomerCluePoolDTO; import cn.fw.valhalla.domain.dto.FollowPoolDTO; +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO; import cn.fw.valhalla.domain.dto.StammkundePoolDTO; import cn.fw.valhalla.domain.enums.*; -import cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO; -import cn.fw.valhalla.domain.query.FollowPoolQueryVO; -import cn.fw.valhalla.domain.query.PoolQuery; -import cn.fw.valhalla.domain.query.StammkundePoolQueryVO; +import cn.fw.valhalla.domain.query.*; import cn.fw.valhalla.domain.vo.AppPageVO; +import cn.fw.valhalla.domain.vo.SecretReportHistoryVO; import cn.fw.valhalla.domain.vo.pool.*; import cn.fw.valhalla.rpc.erp.UserService; import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; @@ -55,6 +54,7 @@ public class PoolBizService { private final UserService userService; private final AffiliationRecordService affiliationRecordService; private final OrderRpcService orderRpcService; + private final SecretReportHistoryService secretReportHistoryService; /** @@ -191,6 +191,36 @@ public class PoolBizService { return vo; } + /** + * 查询通话记录池 + * + * @param query + * @return + */ + public AppPage secretReportList(SecretReportHistoryQuery query) { + BV.isNotEmpty(query.getShopIds(), () -> "人员权限范围不正确,请确认是否有管理权限"); + if (Objects.isNull(query.getOrder())) { + query.setOrderString(" order by call_time asc "); + } + AppPageVO page = AppPageVO.init(query); + long total = secretReportHistoryService.secretReportCount(query); + if (total <= 0) { + return page; + } + page.setTotal(total); + List list = secretReportHistoryService.secretReportList(query); + List appList = new ArrayList<>(); + for (SecretReportHistoryDTO dto : list) { + SecretReportHistoryVO vo = new SecretReportHistoryVO(); + BeanUtils.copyProperties(dto, vo); + vo.setShopName(Optional.ofNullable(oopService.shop(dto.getShopId())).map(ShopDTO::getShortName).orElse(null)); + vo.setCallType(CallTypeEnum.ofValue(dto.getDialType())); + appList.add(vo); + } + page.setData(appList); + return page; + } + private FollowPoolListVO trans2FollowPool(FollowPoolDTO poolDTO) { FollowPoolListVO vo = new FollowPoolListVO(); BeanUtils.copyProperties(poolDTO, vo); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/AbstractFollowStrategy.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/AbstractFollowStrategy.java index f3d0a58..8906e25 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/AbstractFollowStrategy.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/AbstractFollowStrategy.java @@ -3,6 +3,7 @@ package cn.fw.valhalla.service.bus.follow.strategy; import cn.fw.common.cache.locker.DistributedLocker; import cn.fw.common.exception.BusinessException; import cn.fw.common.web.auth.LoginAuthBean; +import cn.fw.valhalla.common.constant.RoleCode; import cn.fw.valhalla.common.utils.DateUtil; import cn.fw.valhalla.common.utils.StringUtils; import cn.fw.valhalla.domain.db.OriginalData; @@ -23,7 +24,9 @@ import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO; import cn.fw.valhalla.rpc.erp.TodoRpcService; import cn.fw.valhalla.rpc.erp.UserService; import cn.fw.valhalla.rpc.erp.dto.BackLogItemDTO; +import cn.fw.valhalla.rpc.erp.dto.PostUserDTO; import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; +import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO; import cn.fw.valhalla.rpc.oop.OopService; import cn.fw.valhalla.rpc.oop.dto.ShopDTO; import cn.fw.valhalla.service.bus.cust.CustomerBizService; @@ -136,10 +139,31 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { @Override public List getRecordList(Long taskId) { - List followRecordList = followRecordService.getRecordList(taskId); + List followRecordList = new ArrayList<>(); + FollowTask task = followTaskService.getById(taskId); + if (Objects.nonNull(task)) { + Long clueId = task.getClueId(); + List taskList = followTaskService.list(Wrappers.lambdaQuery() + .eq(FollowTask::getClueId, clueId) + .ne(FollowTask::getId, taskId) + ); + if (!CollectionUtils.isEmpty(taskList)) { + for (FollowTask followTask : taskList) { + List recordList = followRecordService.getRecordList(followTask.getId()); + if (!CollectionUtils.isEmpty(recordList)) { + followRecordList.addAll(recordList); + } + } + } + } + List recordList = followRecordService.getRecordList(taskId); + if (!CollectionUtils.isEmpty(recordList)) { + followRecordList.addAll(recordList); + } if (CollectionUtils.isEmpty(followRecordList)) { return new ArrayList<>(); } + List records = followRecordList.stream().sorted(Comparator.comparing(FollowRecord::getId)).collect(Collectors.toList()); List recordIds = followRecordList.stream().map(FollowRecord::getId).collect(Collectors.toList()); List attachments = followRecordLogService.getListByRecordIds(recordIds); if (CollectionUtils.isEmpty(attachments)) { @@ -157,7 +181,7 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { vo.setFollowType(followRecordList.get(0).getType()); vo.setUploadTime(attachment.getUploadTime()); vo.setDescribes(attachment.getDescribes()); - int i = queryIndexFromRecords(followRecordList, attachment.getRecordId()); + int i = queryIndexFromRecords(records, attachment.getRecordId()); vo.setTimes(i + 1); list.add(vo); } @@ -801,6 +825,18 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { followRecordService.updateById(record); } + protected void queryTimes(Long clueId, FollowDetailVO vo) { + List list = followTaskService.list(Wrappers.lambdaQuery() + .eq(FollowTask::getClueId, clueId) + ); + if (CollectionUtils.isEmpty(list)) { + vo.setTimes(0); + return; + } + int sum = list.stream().filter(r -> Objects.nonNull(r.getTimes())).mapToInt(FollowTask::getTimes).sum(); + vo.setTimes(sum); + } + private void onStopClue(CustomerCluePool clue, TaskDefeatTypeEnum defeatTypeEnum) { clue.setClueStatus(ClueStatusEnum.FAILURE); clue.setCloseTime(new Date()); @@ -844,6 +880,11 @@ public abstract class AbstractFollowStrategy implements FollowStrategy { if (!TaskStateEnum.ONGOING.equals(task.getState())) { return true; } + boolean isFwgw = FollowTypeEnum.FM.equals(task.getType()) || FollowTypeEnum.RM.equals(task.getType()); + List dataRange = userService.getUserRoleDataRange(task.getFollowUser(), isFwgw ? RoleCode.FWGW : RoleCode.XBGJ); + if (CollectionUtils.isEmpty(dataRange)) { + return true; + } //任务截止日期 final Date deadline = task.getDeadline(); Optional fcsetting = settingBizService.querySettingByType(record.getType(), SettingTypeEnum.FOLLOW_CYCLE, record.getGroupId()); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/ACFollowStrategy.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/ACFollowStrategy.java index 5a82bad..cbeed1f 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/ACFollowStrategy.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/ACFollowStrategy.java @@ -1,6 +1,7 @@ package cn.fw.valhalla.service.bus.follow.strategy.impl; import cn.fw.common.exception.BusinessException; +import cn.fw.common.util.ValidationUtils; import cn.fw.valhalla.common.utils.DateUtil; import cn.fw.valhalla.common.utils.MobileUtil; import cn.fw.valhalla.common.utils.StringUtils; @@ -93,7 +94,7 @@ public class ACFollowStrategy extends AbstractFollowStrategy { ACDetailVO vo = assemble(followRecord.getCustomerId()); vo.setId(followRecord.getId()); vo.setTaskId(followRecord.getTaskId()); - vo.setHadCall(count > 0); + vo.setHadCall(count > 0 || !ValidationUtils.checkMobile(vo.getReportMobile())); vo.setDeadline(Objects.isNull(followRecord.getLimitTime()) ? followRecord.getDeadline() : followRecord.getLimitTime()); return vo; } @@ -315,6 +316,8 @@ public class ACFollowStrategy extends AbstractFollowStrategy { vo.setCustomerId(customer.getId()); vo.setAdviserId(customerDetailDto.getAdviserId()); vo.setAdviserName(customerDetailDto.getAdviserName()); + vo.setCusLevel(customerDetailDto.getCusLevel()); + vo.setArrivalCount(customerDetailDto.getArrivalCount()); vo.setVin(customerDetailDto.getFrameNo()); Optional insuranceDTO = queryInsuInfo(customer.getId()); insuranceDTO.ifPresent(ins -> vo.setInsComName(ins.getTciInsurerName())); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/FMFollowStrategy.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/FMFollowStrategy.java index 31f4730..3102b44 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/FMFollowStrategy.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/FMFollowStrategy.java @@ -80,10 +80,10 @@ public class FMFollowStrategy extends AbstractFollowStrategy { vo.setId(followRecord.getId()); vo.setTaskId(followRecord.getTaskId()); vo.setFMExpiration(followTask.getDeadline()); + queryTimes(followTask.getClueId(), vo); int count = followRecordLogService.count(Wrappers.lambdaQuery() - .eq(FollowRecordLog::getRecordId, followRecord.getId()) + .eq(FollowRecordLog::getTaskId, followRecord.getTaskId()) .eq(FollowRecordLog::getAttType, AttTypeEnum.SMART_PHONE) - .isNotNull(FollowRecordLog::getFeedbackType) ); vo.setHadCall(count > 0); return vo; @@ -197,6 +197,8 @@ public class FMFollowStrategy extends AbstractFollowStrategy { vo.setAdviserName(customerDetailDto.getAdviserName()); vo.setCarModel(customerDetailDto.getBrandName() + " " + customerDetailDto.getSeriesName()); vo.setBuyDate(customerDetailDto.getBuyDate()); + vo.setCusLevel(customerDetailDto.getCusLevel()); + vo.setArrivalCount(customerDetailDto.getArrivalCount()); return vo; } } diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/IRFollowStrategy.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/IRFollowStrategy.java index 8afaf40..b54029f 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/IRFollowStrategy.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/IRFollowStrategy.java @@ -17,7 +17,6 @@ import cn.fw.valhalla.domain.enums.*; import cn.fw.valhalla.domain.vo.follow.*; import cn.fw.valhalla.domain.vo.setting.SettingVO; import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO; -import cn.fw.valhalla.rpc.erp.dto.BackLogItemDTO; import cn.fw.valhalla.rpc.erp.dto.PostUserDTO; import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; import cn.fw.valhalla.rpc.oop.dto.ShopDTO; @@ -86,9 +85,12 @@ public class IRFollowStrategy extends AbstractFollowStrategy { public FollowDetailVO getDetail(Long id) { FollowRecord followRecord = followRecordService.getById(id); BV.notNull(followRecord, "跟进记录不存在"); + FollowTask followTask = followTaskService.getById(followRecord.getTaskId()); + BV.notNull(followTask, "跟进信息不存在"); IRDetailVO vo = assemble(followRecord.getCustomerId()); + queryTimes(followTask.getClueId(), vo); int count = followRecordLogService.count(Wrappers.lambdaQuery() - .eq(FollowRecordLog::getRecordId, followRecord.getId()) + .eq(FollowRecordLog::getTaskId, followRecord.getTaskId()) .eq(FollowRecordLog::getAttType, AttTypeEnum.SMART_PHONE) ); vo.setHadCall(count > 0); @@ -424,6 +426,8 @@ public class IRFollowStrategy extends AbstractFollowStrategy { vo.setExpires(detailDto.getExpires()); vo.setPeriods(detailDto.getPeriods()); vo.setLoanCustomer(detailDto.isLoanCustomer()); + vo.setCusLevel(detailDto.getCusLevel()); + vo.setArrivalCount(detailDto.getArrivalCount()); Optional insuranceDTO = queryInsuInfo(customerId); insuranceDTO.ifPresent(ins -> { vo.setTclInsComName(ins.getTciInsurerName()); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/RMFollowStrategy.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/RMFollowStrategy.java index 2f90110..75bbca9 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/RMFollowStrategy.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/RMFollowStrategy.java @@ -103,15 +103,18 @@ public class RMFollowStrategy extends AbstractFollowStrategy { public FollowDetailVO getDetail(Long id) { FollowRecord followRecord = followRecordService.getById(id); BV.notNull(followRecord, "跟进记录不存在"); + FollowTask followTask = followTaskService.getById(followRecord.getTaskId()); + BV.notNull(followTask, "跟进信息不存在"); RMDetailVO vo = assemble(followRecord.getCustomerId()); int count = followRecordLogService.count(Wrappers.lambdaQuery() - .eq(FollowRecordLog::getRecordId, followRecord.getId()) .eq(FollowRecordLog::getAttType, AttTypeEnum.SMART_PHONE) + .eq(FollowRecordLog::getTaskId, followRecord.getTaskId()) ); vo.setHadCall(count > 0); vo.setId(followRecord.getId()); vo.setTaskId(followRecord.getTaskId()); vo.setDeadline(followRecord.getDeadline()); + queryTimes(followTask.getClueId(), vo); return vo; } @@ -260,6 +263,8 @@ public class RMFollowStrategy extends AbstractFollowStrategy { vo.setAdviserName(customerDetailDto.getAdviserName()); vo.setCarModel(customerDetailDto.getBrandName() + " " + customerDetailDto.getSeriesName()); vo.setLastMileage(customerDetailDto.getCurrentMileage()); + vo.setCusLevel(customerDetailDto.getCusLevel()); + vo.setArrivalCount(customerDetailDto.getArrivalCount()); OriginalData originalData = originalDataService.getOne(Wrappers.lambdaQuery() .eq(OriginalData::getCustomerId, customerId) .eq(OriginalData::getType, DataTypeEnum.FS) diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java new file mode 100644 index 0000000..78c44c2 --- /dev/null +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/SecretReportHistoryService.java @@ -0,0 +1,30 @@ +package cn.fw.valhalla.service.data; + +import cn.fw.valhalla.domain.db.SecretReportHistory; +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO; +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * @author : kurisu + * @className : SecretReportHistoryService + * @description : 通话记录 + * @date: 2021-02-21 14:58 + */ +public interface SecretReportHistoryService extends IService { + /** + * 通话记录池 + * @param query + * @return + */ + List secretReportList(SecretReportHistoryQuery query); + + /** + * 查询总数 + * @param query + * @return + */ + Long secretReportCount(SecretReportHistoryQuery query); +} diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/FollowRecordServiceImpl.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/FollowRecordServiceImpl.java index b69b703..610f0b1 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/FollowRecordServiceImpl.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/FollowRecordServiceImpl.java @@ -44,6 +44,7 @@ public class FollowRecordServiceImpl extends ServiceImpl getRecordList(final Long taskId) { return this.list(Wrappers.lambdaQuery() .eq(FollowRecord::getTaskId, taskId) + .eq(FollowRecord::getAddTodo, Boolean.TRUE) .orderByAsc(FollowRecord::getId) ); } @@ -72,7 +73,7 @@ public class FollowRecordServiceImpl extends ServiceImpllambdaQuery() .eq(FollowRecord::getTaskId, taskId) - .eq(FollowRecord::getOutTime, Boolean.FALSE) + .eq(FollowRecord::getAddTodo, Boolean.FALSE) .isNull(FollowRecord::getFollowTime) ); } diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java new file mode 100644 index 0000000..beb4e5c --- /dev/null +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/SecretReportHistoryServiceImpl.java @@ -0,0 +1,37 @@ +package cn.fw.valhalla.service.data.impl; + +import cn.fw.valhalla.dao.mapper.SecretReportHistoryMapper; +import cn.fw.valhalla.domain.db.SecretReportHistory; +import cn.fw.valhalla.domain.dto.SecretReportHistoryDTO; +import cn.fw.valhalla.domain.query.SecretReportHistoryQuery; +import cn.fw.valhalla.service.data.SecretReportHistoryService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * @author : kurisu + * @className : SecretReportHistoryServiceImpl + * @description : 通话记录 + * @date: 2021-02-21 14:58 + */ +@Slf4j +@Service +public class SecretReportHistoryServiceImpl extends ServiceImpl implements SecretReportHistoryService { + @Override + public List secretReportList(SecretReportHistoryQuery queryVO) { + Integer current = queryVO.getCurrent(); + Integer pageSize = queryVO.getPageSize(); + Integer startIndex = (current - 1) * pageSize; + return Optional.ofNullable(getBaseMapper().secretReportList(startIndex, pageSize, queryVO)).orElse(new ArrayList<>()); + } + + @Override + public Long secretReportCount(SecretReportHistoryQuery query) { + return Optional.ofNullable(getBaseMapper().secretReportCount(query)).orElse(0L); + } +} diff --git a/pom.xml b/pom.xml index 2db3f89..a5f111b 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ cn.fw fw-valhalla-sdk - 1.1.1 + 1.1.3 cn.fw