소스 검색

外呼黑名单功能相关代码

zyy 3 주 전
부모
커밋
6803acd59b

+ 102 - 0
fs-admin/src/main/java/com/fs/company/controller/CompanyVoiceRoboticCallBlacklistController.java

@@ -0,0 +1,102 @@
+package com.fs.company.controller;
+
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.domain.CompanyVoiceRoboticCallBlacklist;
+import com.fs.company.service.ICompanyVoiceRoboticCallBlacklistService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 黑名单Controller
+ *
+ * @author fs
+ * @date 2023-02-23
+ */
+@RestController
+@RequestMapping("/company/companyVoiceRoboticCallBlacklist")
+public class CompanyVoiceRoboticCallBlacklistController extends BaseController
+{
+    @Autowired
+    private ICompanyVoiceRoboticCallBlacklistService companyVoiceRoboticCallBlacklistService;
+
+    /**
+     * 查询黑名单列表
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist)
+    {
+        startPage();
+        List<CompanyVoiceRoboticCallBlacklist> list = companyVoiceRoboticCallBlacklistService.selectCompanyVoiceRoboticCallBlacklistList(companyVoiceRoboticCallBlacklist);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出黑名单列表
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:export')")
+    @Log(title = "黑名单", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(@RequestBody CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist)
+    {
+        List<CompanyVoiceRoboticCallBlacklist> list = companyVoiceRoboticCallBlacklistService.selectCompanyVoiceRoboticCallBlacklistList(companyVoiceRoboticCallBlacklist);
+        ExcelUtil<CompanyVoiceRoboticCallBlacklist> util = new ExcelUtil<CompanyVoiceRoboticCallBlacklist>(CompanyVoiceRoboticCallBlacklist.class);
+        return util.exportExcel(list, "companyVoiceBlacklist");
+    }
+
+    /**
+     * 获取黑名单详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:query')")
+    @GetMapping(value = "/{blacklistId}")
+    public AjaxResult getInfo(@PathVariable("blacklistId") Long blacklistId)
+    {
+        return AjaxResult.success(companyVoiceRoboticCallBlacklistService.selectCompanyVoiceRoboticCallBlacklistById(blacklistId));
+    }
+
+    /**
+     * 新增黑名单
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:add')")
+    @Log(title = "黑名单", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist)
+    {
+        return toAjax(companyVoiceRoboticCallBlacklistService.insertCompanyVoiceRoboticCallBlacklist(companyVoiceRoboticCallBlacklist));
+    }
+
+    /**
+     * 修改黑名单nessType = BusinessType.UPDATE)
+     * */
+    @PutMapping
+    @Log(title = "修改黑名单信息", businessType = BusinessType.INSERT)
+    public AjaxResult edit(@RequestBody CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist)
+    {
+        return toAjax(companyVoiceRoboticCallBlacklistService.updateCompanyVoiceRoboticCallBlacklist(companyVoiceRoboticCallBlacklist));
+    }
+
+    /**
+     * 删除黑名单
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:remove')")
+    @Log(title = "黑名单", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{blacklistIds}")
+    public AjaxResult remove(@PathVariable Long[] blacklistIds)
+    {
+        return toAjax(companyVoiceRoboticCallBlacklistService.deleteCompanyVoiceRoboticCallBlacklistByIds(blacklistIds));
+    }
+
+    @Log(title = "修改黑名单状态", businessType = BusinessType.UPDATE)
+    @PutMapping("/changeStatus")
+    public AjaxResult changeStatus(@RequestBody CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist) {
+        return toAjax(companyVoiceRoboticCallBlacklistService.changeStatus(companyVoiceRoboticCallBlacklist));
+    }
+}

+ 113 - 0
fs-company/src/main/java/com/fs/company/controller/company/CompanyVoiceRoboticCallBlacklistController.java

@@ -0,0 +1,113 @@
+package com.fs.company.controller.company;
+
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.core.page.TableDataInfo;
+import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.ServletUtils;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.domain.CompanyVoiceBlacklist;
+import com.fs.company.domain.CompanyVoiceRoboticCallBlacklist;
+import com.fs.company.service.ICompanyVoiceBlacklistService;
+import com.fs.company.service.ICompanyVoiceRoboticCallBlacklistService;
+import com.fs.framework.security.LoginUser;
+import com.fs.framework.service.TokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 黑名单Controller
+ *
+ * @author fs
+ * @date 2023-02-23
+ */
+@RestController
+@RequestMapping("/company/companyVoiceRoboticCallBlacklist")
+public class CompanyVoiceRoboticCallBlacklistController extends BaseController
+{
+    @Autowired
+    private ICompanyVoiceRoboticCallBlacklistService companyVoiceRoboticCallBlacklistService;
+    @Autowired
+    private TokenService tokenService;
+
+    /**
+     * 查询黑名单列表
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist)
+    {
+        startPage();
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        companyVoiceRoboticCallBlacklist.setCompanyId(loginUser.getCompany().getCompanyId());
+        List<CompanyVoiceRoboticCallBlacklist> list = companyVoiceRoboticCallBlacklistService.selectCompanyVoiceRoboticCallBlacklistList(companyVoiceRoboticCallBlacklist);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出黑名单列表
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:export')")
+    @Log(title = "黑名单", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(@RequestBody CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist)
+    {
+        List<CompanyVoiceRoboticCallBlacklist> list = companyVoiceRoboticCallBlacklistService.selectCompanyVoiceRoboticCallBlacklistList(companyVoiceRoboticCallBlacklist);
+        ExcelUtil<CompanyVoiceRoboticCallBlacklist> util = new ExcelUtil<CompanyVoiceRoboticCallBlacklist>(CompanyVoiceRoboticCallBlacklist.class);
+        return util.exportExcel(list, "companyVoiceBlacklist");
+    }
+
+    /**
+     * 获取黑名单详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:query')")
+    @GetMapping(value = "/{blacklistId}")
+    public AjaxResult getInfo(@PathVariable("blacklistId") Long blacklistId)
+    {
+        return AjaxResult.success(companyVoiceRoboticCallBlacklistService.selectCompanyVoiceRoboticCallBlacklistById(blacklistId));
+    }
+
+    /**
+     * 新增黑名单
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:add')")
+    @Log(title = "黑名单", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist)
+    {
+        return toAjax(companyVoiceRoboticCallBlacklistService.insertCompanyVoiceRoboticCallBlacklist(companyVoiceRoboticCallBlacklist));
+    }
+
+    /**
+     * 修改黑名单nessType = BusinessType.UPDATE)
+     * */
+    @PutMapping
+    @Log(title = "修改黑名单信息", businessType = BusinessType.INSERT)
+    public AjaxResult edit(@RequestBody CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist)
+    {
+        return toAjax(companyVoiceRoboticCallBlacklistService.updateCompanyVoiceRoboticCallBlacklist(companyVoiceRoboticCallBlacklist));
+    }
+
+    /**
+     * 删除黑名单
+     */
+    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:remove')")
+    @Log(title = "黑名单", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{blacklistIds}")
+    public AjaxResult remove(@PathVariable Long[] blacklistIds)
+    {
+        return toAjax(companyVoiceRoboticCallBlacklistService.deleteCompanyVoiceRoboticCallBlacklistByIds(blacklistIds));
+    }
+
+    @Log(title = "修改黑名单状态", businessType = BusinessType.UPDATE)
+    @PutMapping("/changeStatus")
+    public AjaxResult changeStatus(@RequestBody CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist) {
+        return toAjax(companyVoiceRoboticCallBlacklistService.changeStatus(companyVoiceRoboticCallBlacklist));
+    }
+
+
+}

+ 37 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyVoiceRoboticCallBlackLog.java

@@ -0,0 +1,37 @@
+package com.fs.company.domain;
+
+
+import com.fs.common.core.domain.BaseEntity;
+
+import java.util.Date;
+
+/**
+ * 黑名单对象 company_voice_blacklist
+ * @author ZhuanZ(无密码)
+ */
+public class CompanyVoiceRoboticCallBlackLog extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    private Long companyId;
+
+    private Long roboticId;
+
+    private Long customerId;
+
+    private String externalUserId;
+
+    private String phone;
+
+    private String blockReason;
+
+    private Long blacklistId;
+
+    private String requestData;
+
+    private Date createTime;
+
+
+}

+ 82 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyVoiceRoboticCallBlacklist.java

@@ -0,0 +1,82 @@
+package com.fs.company.domain;
+
+
+import com.fs.common.core.domain.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * 黑名单对象 company_voice_blacklist
+ * @author ZhuanZ(无密码)
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CompanyVoiceRoboticCallBlacklist extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
+
+    /**
+     * 业务类型
+     */
+    private String businessType;
+
+    /**
+     * 1手机号 2客户ID 3企微客户ID
+     */
+    private Integer targetType;
+
+    /**
+     * 对象值
+     */
+    private String targetValue;
+
+    /**
+     * 公司ID
+     */
+    private Long companyId;
+
+    /**
+     * 拉黑原因
+     */
+    private String reason;
+
+    /**
+     * 来源:1手工添加 2系统
+     */
+    private Integer source;
+
+    /**
+     * 状态:1生效 0禁用
+     */
+    private Integer status;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    private String createBy;
+
+    private Date createTime;
+
+    private String updateBy;
+
+    private Date updateTime;
+
+    /**
+     * 逻辑删除:0否 1是
+     */
+    private Integer deleted;
+
+    /**
+     * 只看全局黑名单
+     */
+    private Boolean onlyGlobal;
+
+}

+ 83 - 0
fs-service/src/main/java/com/fs/company/enums/BusinessTypeEnum.java

@@ -0,0 +1,83 @@
+package com.fs.company.enums;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 业务类型枚举
+ *
+ * @author ZhuanZ
+ */
+public enum BusinessTypeEnum {
+
+    /**
+     * 外呼
+     */
+    CALL("CALL", "外呼"),
+
+    /**
+     * 加微
+     */
+    ADD_WX("ADD_WX", "加微"),
+
+    /**
+     * 短信
+     */
+    SMS("SMS", "短信");
+
+    private final String code;
+    private final String desc;
+
+    BusinessTypeEnum(String code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    /**
+     * 根据 code 获取枚举
+     */
+    public static BusinessTypeEnum fromCode(String code) {
+        if (code == null) {
+            return null;
+        }
+        for (BusinessTypeEnum item : values()) {
+            if (item.code.equalsIgnoreCase(code)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 校验是否为合法业务类型
+     */
+    public static boolean isValid(String code) {
+        return fromCode(code) != null;
+    }
+
+    /**
+     * 获取所有 code 列表
+     */
+    public static List<String> getCodes() {
+        return Arrays.stream(values())
+                .map(BusinessTypeEnum::getCode)
+                .collect(Collectors.toList());
+    }
+
+    /**
+     * 判断是否相等(忽略大小写)
+     */
+    public boolean equalsCode(String code) {
+        return this.code.equalsIgnoreCase(code);
+    }
+
+}

+ 92 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyVoiceRoboticCallBlacklistMapper.java

@@ -0,0 +1,92 @@
+package com.fs.company.mapper;
+
+import com.fs.company.domain.CompanyVoiceRoboticCallBlacklist;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * 黑名单Mapper接口
+ * 
+ * @author fs
+ * @date 2023-02-23
+ */
+public interface CompanyVoiceRoboticCallBlacklistMapper
+{
+    /**
+     * 查询黑名单
+     * 
+     * @param blacklistId 黑名单ID
+     * @return 黑名单
+     */
+    public CompanyVoiceRoboticCallBlacklist selectCompanyVoiceBlacklistById(Long blacklistId);
+
+    /**
+     * 查询黑名单列表
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 黑名单集合
+     */
+    public List<CompanyVoiceRoboticCallBlacklist> selectCompanyVoiceBlacklistList(CompanyVoiceRoboticCallBlacklist companyCallBlacklist);
+
+    /**
+     * 新增黑名单
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 结果
+     */
+    public int insertCompanyVoiceBlacklist(CompanyVoiceRoboticCallBlacklist companyCallBlacklist);
+
+    /**
+     * 修改黑名单
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 结果
+     */
+    public int updateCompanyVoiceBlacklist(CompanyVoiceRoboticCallBlacklist companyCallBlacklist);
+
+    /**
+     * 删除黑名单
+     * 
+     * @param blacklistId 黑名单ID
+     * @return 结果
+     */
+    public int deleteCompanyVoiceBlacklistById(Long blacklistId);
+
+    /**
+     * 批量删除黑名单
+     * 
+     * @param blacklistIds 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteCompanyVoiceBlacklistByIds(Long[] blacklistIds);
+    @Select("select ifnull(count(1),0) from company_voice_blacklist where mobile=#{mobile} limit 1")
+    int selectCompanyVoiceBlacklistByMobile(String mobile);
+
+    /**
+     * 黑名单查重
+     */
+    CompanyVoiceRoboticCallBlacklist selectDuplicate(@Param("id") Long id,
+                                                     @Param("companyId") Long companyId,
+                                                     @Param("targetType") Integer targetType,
+                                                     @Param("targetValue") String targetValue);
+
+
+    /**
+     * 查询当前生效黑名单
+     */
+    CompanyVoiceRoboticCallBlacklist selectActiveByTarget(@Param("companyId") Long companyId,
+                                                          @Param("businessType") String businessType,
+                                                          @Param("targetValue") String targetValue);
+
+    /**
+     * 查询全局黑名单
+     */
+    CompanyVoiceRoboticCallBlacklist selectGlobalActiveByTarget(@Param("businessType") String businessType,
+                                                                @Param("targetValue") String targetValue);
+
+
+    int updateStatusById(CompanyVoiceRoboticCallBlacklist entity);
+
+}

+ 34 - 0
fs-service/src/main/java/com/fs/company/param/CompanyVoiceRoboticCallBlacklistCheckParam.java

@@ -0,0 +1,34 @@
+package com.fs.company.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author ZhuanZ(无密码)
+ */
+@Data
+public class CompanyVoiceRoboticCallBlacklistCheckParam implements Serializable {
+    /**
+     * 公司ID
+     */
+    private Long companyId;
+
+    /**
+     * 业务类型
+     */
+    private String businessType;
+
+    /**
+     * 手机号
+     */
+    private String targetValue;
+
+    /**
+     * 对象类型
+     */
+    private Integer targetType;
+
+
+}
+

+ 73 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyVoiceRoboticCallBlacklistService.java

@@ -0,0 +1,73 @@
+package com.fs.company.service;
+
+import com.fs.company.domain.CompanyVoiceRoboticCallBlacklist;
+import com.fs.company.param.CompanyVoiceRoboticCallBlacklistCheckParam;
+import com.fs.company.vo.CompanyVoiceRoboticCallBlacklistCheckVO;
+
+import java.util.List;
+
+/**
+ * 黑名单Service接口
+ * 
+ * @author fs
+ * @date 2023-02-23
+ */
+public interface ICompanyVoiceRoboticCallBlacklistService
+{
+    /**
+     * 查询黑名单
+     * 
+     * @param blacklistId 黑名单ID
+     * @return 黑名单
+     */
+    public CompanyVoiceRoboticCallBlacklist selectCompanyVoiceRoboticCallBlacklistById(Long blacklistId);
+
+    /**
+     * 查询黑名单列表
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 黑名单集合
+     */
+    public List<CompanyVoiceRoboticCallBlacklist> selectCompanyVoiceRoboticCallBlacklistList(CompanyVoiceRoboticCallBlacklist companyCallBlacklist);
+
+    /**
+     * 新增黑名单
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 结果
+     */
+    public int insertCompanyVoiceRoboticCallBlacklist(CompanyVoiceRoboticCallBlacklist companyCallBlacklist);
+
+    /**
+     * 修改黑名单
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 结果
+     */
+    public int updateCompanyVoiceRoboticCallBlacklist(CompanyVoiceRoboticCallBlacklist companyCallBlacklist);
+
+    /**
+     * 批量删除黑名单
+     * 
+     * @param blacklistIds 需要删除的黑名单ID
+     * @return 结果
+     */
+    public int deleteCompanyVoiceRoboticCallBlacklistByIds(Long[] blacklistIds);
+
+    /**
+     * 删除黑名单信息
+     * 
+     * @param blacklistId 黑名单ID
+     * @return 结果
+     */
+    public int deleteCompanyVoiceRoboticCallBlacklistById(Long blacklistId);
+
+    int selectCompanyCallBlacklistByMobile(String mobile);
+
+    int changeStatus(CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist);
+
+    /**
+     * 外呼前检查是否命中黑名单
+     */
+    CompanyVoiceRoboticCallBlacklistCheckVO checkBlacklist(CompanyVoiceRoboticCallBlacklistCheckParam companyVoiceRoboticCallBlacklistCheckParam);
+}

+ 227 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyVoiceRoboticCallBlacklistServiceImpl.java

@@ -0,0 +1,227 @@
+package com.fs.company.service.impl;
+
+import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.ServletUtils;
+import com.fs.company.domain.CompanyVoiceRoboticCallBlacklist;
+import com.fs.company.mapper.CompanyVoiceRoboticCallBlacklistMapper;
+import com.fs.company.param.CompanyVoiceRoboticCallBlacklistCheckParam;
+import com.fs.company.service.ICompanyVoiceRoboticCallBlacklistService;
+import com.fs.company.vo.CompanyVoiceRoboticCallBlacklistCheckVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+
+/**
+ * 黑名单Service业务层处理
+ * 
+ * @author fs
+ * @date 2023-02-23
+ */
+@Service
+public class CompanyVoiceRoboticCallBlacklistServiceImpl implements ICompanyVoiceRoboticCallBlacklistService
+{
+    @Autowired
+    private CompanyVoiceRoboticCallBlacklistMapper companyVoiceRoboticCallBlacklistMapper;
+
+    /**
+     * 查询黑名单
+     * 
+     * @param blacklistId 黑名单ID
+     * @return 黑名单
+     */
+    @Override
+    public CompanyVoiceRoboticCallBlacklist selectCompanyVoiceRoboticCallBlacklistById(Long blacklistId)
+    {
+        return companyVoiceRoboticCallBlacklistMapper.selectCompanyVoiceBlacklistById(blacklistId);
+    }
+
+    /**
+     * 查询黑名单列表
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 黑名单
+     */
+    @Override
+    public List<CompanyVoiceRoboticCallBlacklist> selectCompanyVoiceRoboticCallBlacklistList(CompanyVoiceRoboticCallBlacklist companyCallBlacklist)
+    {
+        return companyVoiceRoboticCallBlacklistMapper.selectCompanyVoiceBlacklistList(companyCallBlacklist);
+    }
+
+    /**
+     * 新增黑名单
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 结果
+     */
+    @Override
+    public int insertCompanyVoiceRoboticCallBlacklist(CompanyVoiceRoboticCallBlacklist companyCallBlacklist)
+    {
+        companyCallBlacklist.setCreateTime(DateUtils.getNowDate());
+        return companyVoiceRoboticCallBlacklistMapper.insertCompanyVoiceBlacklist(companyCallBlacklist);
+    }
+
+    /**
+     * 修改黑名单
+     * 
+     * @param companyCallBlacklist 黑名单
+     * @return 结果
+     */
+    @Override
+    public int updateCompanyVoiceRoboticCallBlacklist(CompanyVoiceRoboticCallBlacklist companyCallBlacklist)
+    {
+        companyCallBlacklist.setUpdateTime(DateUtils.getNowDate());
+        return companyVoiceRoboticCallBlacklistMapper.updateCompanyVoiceBlacklist(companyCallBlacklist);
+    }
+
+    /**
+     * 批量删除黑名单
+     * 
+     * @param blacklistIds 需要删除的黑名单ID
+     * @return 结果
+     */
+    @Override
+    public int deleteCompanyVoiceRoboticCallBlacklistByIds(Long[] blacklistIds)
+    {
+        return companyVoiceRoboticCallBlacklistMapper.deleteCompanyVoiceBlacklistByIds(blacklistIds);
+    }
+
+    /**
+     * 删除黑名单信息
+     * 
+     * @param blacklistId 黑名单ID
+     * @return 结果
+     */
+    @Override
+    public int deleteCompanyVoiceRoboticCallBlacklistById(Long blacklistId)
+    {
+        return companyVoiceRoboticCallBlacklistMapper.deleteCompanyVoiceBlacklistById(blacklistId);
+    }
+
+    @Override
+    public int selectCompanyCallBlacklistByMobile(String mobile) {
+        return companyVoiceRoboticCallBlacklistMapper.selectCompanyVoiceBlacklistByMobile(mobile);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int changeStatus(CompanyVoiceRoboticCallBlacklist companyVoiceRoboticCallBlacklist) {
+        CompanyVoiceRoboticCallBlacklist db = companyVoiceRoboticCallBlacklistMapper.selectCompanyVoiceBlacklistById(companyVoiceRoboticCallBlacklist.getId());
+        if (db == null) {
+            throw new RuntimeException("黑名单记录不存在");
+        }
+
+        CompanyVoiceRoboticCallBlacklist entity = new CompanyVoiceRoboticCallBlacklist();
+        entity.setId(companyVoiceRoboticCallBlacklist.getId());
+        entity.setStatus(companyVoiceRoboticCallBlacklist.getStatus());
+        return companyVoiceRoboticCallBlacklistMapper.updateStatusById(entity);
+    }
+
+    /**
+     * 校验黑名单
+     */
+    @Override
+    public CompanyVoiceRoboticCallBlacklistCheckVO checkBlacklist(CompanyVoiceRoboticCallBlacklistCheckParam param) {
+        if (param == null || param.getCompanyId() == null
+                || !StringUtils.hasText(param.getBusinessType())
+                || !StringUtils.hasText(param.getTargetValue())) {
+            return CompanyVoiceRoboticCallBlacklistCheckVO.paramNull("校验参数不能为空");
+        }
+
+        String targetValue = normalizeTargetValue(param.getTargetType(), param.getTargetValue());
+
+        // 1. 有 companyId,先查公司级黑名单
+        if (param.getCompanyId() != null) {
+            CompanyVoiceRoboticCallBlacklist companyHit =
+                    companyVoiceRoboticCallBlacklistMapper.selectActiveByTarget(
+                            param.getCompanyId(),
+                            param.getBusinessType(),
+                            targetValue
+                    );
+
+            if (companyHit != null) {
+                return CompanyVoiceRoboticCallBlacklistCheckVO.reject(
+                        companyHit.getId(),
+                        companyHit.getBusinessType(),
+                        companyHit.getTargetType(),
+                        companyHit.getTargetValue(),
+                        buildReason(companyHit, "公司级黑名单")
+                );
+            }
+        }
+
+//        CompanyVoiceRoboticCallBlacklist hit = companyVoiceRoboticCallBlacklistMapper.selectActiveByTarget(
+//                param.getCompanyId(),
+//                param.getBusinessType(),
+//                targetValue
+//        );
+
+//        if (hit == null) {
+//            return CompanyVoiceRoboticCallBlacklistCheckVO.pass(param.getBusinessType());
+//        }
+//
+//        return CompanyVoiceRoboticCallBlacklistCheckVO.reject(
+//                hit.getId(),
+//                hit.getBusinessType(),
+//                hit.getTargetType(),
+//                hit.getTargetValue(),
+//                buildReason(hit)
+//        );
+        // 2. 查全局黑名单
+        CompanyVoiceRoboticCallBlacklist globalHit = companyVoiceRoboticCallBlacklistMapper.selectGlobalActiveByTarget(param.getBusinessType(),targetValue);
+
+        if (globalHit != null) {
+            return CompanyVoiceRoboticCallBlacklistCheckVO.reject(
+                    globalHit.getId(),
+                    globalHit.getBusinessType(),
+                    globalHit.getTargetType(),
+                    globalHit.getTargetValue(),
+                    buildReason(globalHit, "全局黑名单")
+            );
+        }
+        return CompanyVoiceRoboticCallBlacklistCheckVO.pass(param.getBusinessType());
+
+    }
+
+    /**
+     * 归一化对象值
+     */
+    private String normalizeTargetValue(Integer targetType, String targetValue) {
+        if (!StringUtils.hasText(targetValue)) {
+            return targetValue;
+        }
+        String value = targetValue.trim();
+
+        // 手机号归一化
+        if (Integer.valueOf(1).equals(targetType)) {
+            value = value.replace(" ", "")
+                    .replace("-", "")
+                    .replace("+86", "")
+                    .replace("(", "")
+                    .replace(")", "");
+        }
+        return value;
+    }
+
+    private String buildReason(CompanyVoiceRoboticCallBlacklist hit,String scopeDesc) {
+        String prefix;
+        if (Integer.valueOf(1).equals(hit.getTargetType())) {
+            prefix = "手机号命中" + scopeDesc;
+        } else if (Integer.valueOf(2).equals(hit.getTargetType())) {
+            prefix = "客户ID命中" + scopeDesc;
+        } else if (Integer.valueOf(3).equals(hit.getTargetType())) {
+            prefix = "企微客户ID命中" + scopeDesc;
+        } else {
+            prefix = "命中" + scopeDesc;
+        }
+
+        if (StringUtils.hasText(hit.getReason())) {
+            return prefix + ":" + hit.getReason();
+        }
+        return prefix;
+    }
+
+
+}

+ 78 - 0
fs-service/src/main/java/com/fs/company/vo/CompanyVoiceRoboticCallBlacklistCheckVO.java

@@ -0,0 +1,78 @@
+package com.fs.company.vo;
+
+import lombok.Data;
+
+/**
+ * @author ZhuanZ(无密码)
+ */
+@Data
+public class CompanyVoiceRoboticCallBlacklistCheckVO {
+
+    /**
+     * 是否通过
+     */
+    private Boolean pass;
+
+    /**
+     * 是否命中黑名单
+     */
+    private Boolean hitBlacklist;
+
+    /**
+     * 命中的黑名单ID
+     */
+    private Long blacklistId;
+
+    /**
+     * 业务类型
+     */
+    private String businessType;
+
+    /**
+     * 对象类型
+     */
+    private Integer targetType;
+
+    /**
+     * 对象值
+     */
+    private String targetValue;
+
+    /**
+     * 原因
+     */
+    private String reason;
+
+    public static CompanyVoiceRoboticCallBlacklistCheckVO pass(String businessType) {
+        CompanyVoiceRoboticCallBlacklistCheckVO vo = new CompanyVoiceRoboticCallBlacklistCheckVO();
+        vo.setPass(true);
+        vo.setHitBlacklist(false);
+        vo.setBusinessType(businessType);
+        return vo;
+    }
+
+    public static CompanyVoiceRoboticCallBlacklistCheckVO reject(Long blacklistId,
+                                                   String businessType,
+                                                   Integer targetType,
+                                                   String targetValue,
+                                                   String reason) {
+        CompanyVoiceRoboticCallBlacklistCheckVO vo = new CompanyVoiceRoboticCallBlacklistCheckVO();
+        vo.setPass(false);
+        vo.setHitBlacklist(true);
+        vo.setBlacklistId(blacklistId);
+        vo.setBusinessType(businessType);
+        vo.setTargetType(targetType);
+        vo.setTargetValue(targetValue);
+        vo.setReason(reason);
+        return vo;
+    }
+
+    public static CompanyVoiceRoboticCallBlacklistCheckVO paramNull(String msg) {
+        CompanyVoiceRoboticCallBlacklistCheckVO vo = new CompanyVoiceRoboticCallBlacklistCheckVO();
+        vo.setPass(false);
+        vo.setHitBlacklist(false);
+        vo.setReason(msg);
+        return vo;
+    }
+
+}

+ 203 - 0
fs-service/src/main/resources/mapper/company/CompanyVoiceRoboticCallBlacklistMapper.xml

@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.company.mapper.CompanyVoiceRoboticCallBlacklistMapper">
+    
+    <resultMap type="CompanyVoiceRoboticCallBlacklist" id="CompanyVoiceBlacklistResult">
+        <id property="id" column="id"/>
+        <result property="businessType" column="business_type"/>
+        <result property="targetType" column="target_type"/>
+        <result property="targetValue" column="target_value"/>
+        <result property="companyId" column="company_id"/>
+        <result property="reason" column="reason"/>
+        <result property="source" column="source"/>
+        <result property="status" column="status"/>
+        <result property="remark" column="remark"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="deleted" column="deleted"/>
+    </resultMap>
+
+    <sql id="selectCompanyVoiceBlacklistVo">
+        select id,
+               business_type,
+               target_type,
+               target_value,
+               company_id,
+               reason,
+               source,
+               status,
+               remark,
+               create_by,
+               create_time,
+               update_by,
+               update_time
+        from company_voice_robotic_call_blacklist
+    </sql>
+
+    <select id="selectCompanyVoiceBlacklistList" parameterType="com.fs.company.domain.CompanyVoiceRoboticCallBlacklist" resultMap="CompanyVoiceBlacklistResult">
+        <include refid="selectCompanyVoiceBlacklistVo"/>
+        <where>
+            <if test="companyId != null">
+                and company_id = #{companyId}
+            </if>
+            <if test="businessType != null and businessType != ''">
+                and business_type = #{businessType}
+            </if>
+            <if test="targetType != null">
+                and target_type = #{targetType}
+            </if>
+            <if test="targetValue != null and targetValue != ''">
+                and target_value like concat('%', #{targetValue}, '%')
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="source != null">
+                and source = #{source}
+            </if>
+            <if test="beginTime != null">
+                and create_time <![CDATA[ >= ]]> #{beginTime}
+            </if>
+            <if test="endTime != null">
+                and create_time <![CDATA[ <= ]]> #{endTime}
+            </if>
+            <if test="onlyGlobal != null and onlyGlobal">
+                and company_id is null
+            </if>
+        </where>
+        order by id desc
+    </select>
+    
+    <select id="selectCompanyVoiceBlacklistById" parameterType="Long" resultMap="CompanyVoiceBlacklistResult">
+        <include refid="selectCompanyVoiceBlacklistVo"/>
+        where id = #{blacklistId}
+    </select>
+
+    <insert id="insertCompanyVoiceBlacklist" parameterType="CompanyVoiceRoboticCallBlacklist" useGeneratedKeys="true" keyProperty="id">
+        insert into company_voice_robotic_call_blacklist (
+            business_type,
+            target_type,
+            target_value,
+            company_id,
+            reason,
+            source,
+            status,
+            remark,
+            create_by,
+            create_time,
+            update_by,
+            update_time,
+            deleted
+        ) values (
+                     #{businessType},
+                     #{targetType},
+                     #{targetValue},
+                     #{companyId},
+                     #{reason},
+                     #{source},
+                     #{status},
+                     #{remark},
+                     #{createBy},
+                     now(),
+                     #{updateBy},
+                     now(),
+                     0
+                 )
+    </insert>
+
+    <update id="updateCompanyVoiceBlacklist" parameterType="CompanyVoiceRoboticCallBlacklist">
+        update company_voice_robotic_call_blacklist
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="businessType != null">business_type = #{businessType},</if>
+            <if test="targetValue != null">target_value = #{targetValue},</if>
+            <if test="targetType != null">target_type = #{targetType},</if>
+            <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="reason != null">reason = #{reason},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+    <update id="updateStatusById" parameterType="com.fs.company.domain.CompanyVoiceRoboticCallBlacklist">
+        update company_voice_robotic_call_blacklist
+        set
+            status = #{status},
+            update_time = now()
+        where id = #{id}
+          and deleted = 0
+    </update>
+
+    <delete id="deleteCompanyVoiceBlacklistById" parameterType="Long">
+        delete from company_voice_blacklist where blacklist_id = #{blacklistId}
+    </delete>
+
+    <delete id="deleteCompanyVoiceBlacklistByIds" parameterType="String">
+        delete from company_voice_robotic_call_blacklist where id in
+        <foreach item="blacklistId" collection="array" open="(" separator="," close=")">
+            #{blacklistId}
+        </foreach>
+    </delete>
+
+    <select id="selectDuplicate" resultType="com.fs.company.domain.CompanyVoiceRoboticCallBlacklist"></select>
+    <select id="selectActiveByTarget" resultType="com.fs.company.domain.CompanyVoiceRoboticCallBlacklist">
+            select
+            id,
+            business_type,
+            target_type,
+            target_value,
+            company_id,
+            reason,
+            source,
+            status,
+            remark,
+            create_by,
+            create_time,
+            update_by,
+            update_time,
+            deleted
+            from company_voice_robotic_call_blacklist
+            where deleted = 0
+            and status = 1
+            and company_id = #{companyId}
+            <if test="targetType != null and targetType != ''">
+            and target_type = #{targetType}
+            </if>
+            and target_value = #{targetValue}
+            <if test="businessType != null and businessType != ''">
+                and business_type = #{businessType}
+            </if>
+            limit 1
+    </select>
+    <select id="selectGlobalActiveByTarget" resultType="com.fs.company.domain.CompanyVoiceRoboticCallBlacklist">
+        select
+        id,
+        business_type,
+        target_type,
+        target_value,
+        company_id,
+        reason,
+        source,
+        status,
+        remark,
+        create_by,
+        create_time,
+        update_by,
+        update_time,
+        deleted
+        from company_voice_robotic_call_blacklist
+        where deleted = 0
+        and status = 1
+        and company_id is null
+        and target_type = #{targetType}
+        <if test="businessType != null and businessType != ''">
+            and business_type = #{businessType}
+        </if>
+        limit 1
+    </select>
+
+</mapper>