- agent.detail.query / property.detail.query:主体详情 + invoice_info
全量抬头列表(默认条优先),行权限复用列表过滤语义
- 新增 InvoiceQueries 共享发票查询助手;InvoiceInfo 实体/Mapper
按线上库 codegen 生成(m0 白名单加 invoice_info)
- Properyt.customerId 补 @TableField("customerId"):库中驼峰列名,
否则映射到不存在的 customer_id(prod 曾报 Unknown column)
- seed-dev.sql 补两个详情工具的 scope 绑定;PermissionServiceTest
补详情行权限断言(合并远端 district 测试冲突)
- 新增 deploy/test-up.sh:本机测试环境一键脚本(构建→重启→刷新
scope 绑定→自检);.env.example 修正引导变量名 APP_ 前缀误写
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
package me.iiv.agent.entity.m0;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 发票信息表
|
||||
* </p>
|
||||
*
|
||||
* @author codegen
|
||||
* @since 2026-09-08
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@TableName("invoice_info")
|
||||
public class InvoiceInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 创建id
|
||||
*/
|
||||
private Long createId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createName;
|
||||
|
||||
/**
|
||||
* 修改id
|
||||
*/
|
||||
private Long modifyId;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String modifyName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date modifyTime;
|
||||
|
||||
/**
|
||||
* 数据状态
|
||||
*/
|
||||
private Integer softDelete;
|
||||
|
||||
/**
|
||||
* 类型(0:代理;1:物业)
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 客户名称
|
||||
*/
|
||||
private String customerName;
|
||||
|
||||
/**
|
||||
* 开票名称
|
||||
*/
|
||||
private String invoiceName;
|
||||
|
||||
/**
|
||||
* 统一社会信用代码
|
||||
*/
|
||||
private String identificationNumber;
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String contact;
|
||||
|
||||
/**
|
||||
* 联系人邮箱
|
||||
*/
|
||||
private String mail;
|
||||
|
||||
/**
|
||||
* 银行账户户名称
|
||||
*/
|
||||
private String accountName;
|
||||
|
||||
/**
|
||||
* 银行账号
|
||||
*/
|
||||
private String accountNo;
|
||||
|
||||
/**
|
||||
* 开户行名称
|
||||
*/
|
||||
private String accountBank;
|
||||
|
||||
/**
|
||||
* 开票通讯地址
|
||||
*/
|
||||
private String invoiceAddress;
|
||||
|
||||
/**
|
||||
* 开票联系电话
|
||||
*/
|
||||
private String invoiceContact;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String memo;
|
||||
|
||||
/**
|
||||
* 默认标识(0:非默认;1:默认)
|
||||
*/
|
||||
private Integer defaultFlag;
|
||||
|
||||
/**
|
||||
* 发票抬头类型(0:企业单位;1:个人|非企业)
|
||||
*/
|
||||
private Integer invoiceType;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.iiv.agent.entity.m0;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -119,7 +120,10 @@ public class Properyt implements Serializable {
|
||||
|
||||
/**
|
||||
* 客户id自动生成
|
||||
* 注意:库中列名为驼峰 customerId(dev/prod 一致),需显式指定,
|
||||
* 否则 MyBatis-Plus 默认驼峰转下划线会映射成不存在的 customer_id。
|
||||
*/
|
||||
@TableField("customerId")
|
||||
private String customerId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package me.iiv.agent.mapper.m0;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import me.iiv.agent.entity.m0.InvoiceInfo;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 发票信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author codegen
|
||||
* @since 2026-09-08
|
||||
*/
|
||||
public interface InvoiceInfoMapper extends BaseMapper<InvoiceInfo> {
|
||||
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package me.iiv.agent.mcp.tool;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import me.iiv.agent.entity.m0.Agent;
|
||||
import me.iiv.agent.entity.m0.InvoiceInfo;
|
||||
import me.iiv.agent.entity.m0.User;
|
||||
import me.iiv.agent.mapper.m0.AgentMapper;
|
||||
import me.iiv.agent.mapper.m0.InvoiceInfoMapper;
|
||||
import me.iiv.agent.mcp.ToolObject;
|
||||
import me.iiv.agent.mcp.XqTool;
|
||||
import me.iiv.agent.permission.PermissionService;
|
||||
@@ -31,10 +33,13 @@ public class AgentTools implements ToolObject {
|
||||
private static final int MAX_ROWS = 100;
|
||||
|
||||
final AgentMapper agentMapper;
|
||||
final InvoiceInfoMapper invoiceInfoMapper;
|
||||
final PermissionService permissionService;
|
||||
|
||||
public AgentTools(AgentMapper agentMapper, PermissionService permissionService) {
|
||||
public AgentTools(AgentMapper agentMapper, InvoiceInfoMapper invoiceInfoMapper,
|
||||
PermissionService permissionService) {
|
||||
this.agentMapper = agentMapper;
|
||||
this.invoiceInfoMapper = invoiceInfoMapper;
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
@@ -154,4 +159,78 @@ public class AgentTools implements ToolObject {
|
||||
result.put("records", records);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询代理商详情(含发票信息)。行权限复用列表精确查询语义:
|
||||
* 代理商只能查自己或直属下级,总部不限。
|
||||
* invoices 来自 m0.invoice_info(type=0 + customer_id=id),含该代理名下全部抬头。
|
||||
*/
|
||||
@XqTool(category = "customer", kind = "read")
|
||||
@Tool(name = "agent.detail.query", description = "查询代理商详情(含发票信息)。"
|
||||
+ "行级权限:代理商身份的用户(权限组 isagent=1)只能查询自己或直属下级代理;总部身份(isagent=0)可查询任意合法 id。"
|
||||
+ "返回 record(代理商基础信息 + 默认发票镜像字段 + 纳税信息)和 invoices(该代理名下全部发票抬头,defaultFlag=1 为默认抬头,按默认优先+修改时间倒序)。"
|
||||
+ "taxpayerType 含义:0=一般纳税人 1=小规模 2=个人;invoiceType 含义:0=企业单位 1=个人|非企业。"
|
||||
+ "id 不存在或无权限时 record 为 null 并在 notice 字段说明。")
|
||||
public Map<String, Object> agentDetailQuery(
|
||||
@ToolParam(required = true, description = "代理商 id;代理商仅限自己或直属下级") Long id) {
|
||||
User user = AuthContextHolder.get().getUser();
|
||||
LambdaQueryWrapper<Agent> wrapper = new LambdaQueryWrapper<Agent>()
|
||||
.eq(Agent::getSoftDelete, 0);
|
||||
permissionService.applyAgentListRowFilter(wrapper, user, id);
|
||||
Agent agent = agentMapper.selectOne(wrapper);
|
||||
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
if (agent == null) {
|
||||
result.put("record", null);
|
||||
result.put("invoices", List.of());
|
||||
result.put("notice", "id=" + id + " 不存在或当前身份无权查看");
|
||||
return result;
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Map<String, Object> record = new LinkedHashMap<>();
|
||||
record.put("id", agent.getId());
|
||||
record.put("name", agent.getName());
|
||||
record.put("shortName", agent.getShortName());
|
||||
record.put("level", agent.getLevel());
|
||||
record.put("channelNo", agent.getChannelNo());
|
||||
record.put("serialnumber", agent.getSerialnumber());
|
||||
record.put("supervisorName", resolveSupervisorName(agent));
|
||||
record.put("province", agent.getProvince());
|
||||
record.put("city", agent.getCity());
|
||||
record.put("countyseat", agent.getCountyseat());
|
||||
record.put("address", agent.getAddress());
|
||||
record.put("agencyarea", agent.getAgencyarea());
|
||||
record.put("contact", agent.getContact());
|
||||
record.put("phone", agent.getPhone());
|
||||
record.put("mail", agent.getMail());
|
||||
record.put("saleName", agent.getSaleName());
|
||||
record.put("memo", agent.getMemo());
|
||||
record.put("createTime", agent.getCreateTime() == null ? null : sdf.format(agent.getCreateTime()));
|
||||
// 默认发票镜像字段(与 invoice_info 中 default_flag=1 的抬头同步)
|
||||
record.put("invoiceName", agent.getInvoiceName());
|
||||
record.put("invoiceType", agent.getInvoiceType());
|
||||
record.put("identificationNumber", agent.getIdentificationNumber());
|
||||
record.put("accountName", agent.getAccountName());
|
||||
record.put("accountNo", agent.getAccountNo());
|
||||
record.put("accountBank", agent.getAccountBank());
|
||||
record.put("invoiceAddress", agent.getInvoiceAddress());
|
||||
record.put("invoiceContact", agent.getInvoiceContact());
|
||||
record.put("lastInvoiceTime", agent.getLastInvoiceTime() == null ? null : sdf.format(agent.getLastInvoiceTime()));
|
||||
// 纳税信息(agent 独有)
|
||||
record.put("taxpayerType", agent.getTaxpayerType());
|
||||
record.put("taxpayerPoint", agent.getTaxpayerPoint());
|
||||
record.put("taxpayerServiceCharge", agent.getTaxpayerServiceCharge());
|
||||
result.put("record", record);
|
||||
result.put("invoices", InvoiceQueries.query(invoiceInfoMapper, id, 0));
|
||||
return result;
|
||||
}
|
||||
|
||||
private String resolveSupervisorName(Agent agent) {
|
||||
if (agent.getSupervisorId() == null || agent.getSupervisorId() == 0) {
|
||||
return "-";
|
||||
}
|
||||
Agent supervisor = agentMapper.selectById(agent.getSupervisorId());
|
||||
return supervisor == null ? "-" : supervisor.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package me.iiv.agent.mcp.tool;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import me.iiv.agent.entity.m0.InvoiceInfo;
|
||||
import me.iiv.agent.mapper.m0.InvoiceInfoMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* invoice_info 抬头查询助手(m0 库,type:0=代理 1=物业)。
|
||||
* 默认条(defaultFlag=1)优先,其余按修改时间倒序。
|
||||
*/
|
||||
final class InvoiceQueries {
|
||||
|
||||
private InvoiceQueries() {
|
||||
}
|
||||
|
||||
static List<Map<String, Object>> query(InvoiceInfoMapper mapper, Long customerId, int type) {
|
||||
List<InvoiceInfo> invoices = mapper.selectList(new LambdaQueryWrapper<InvoiceInfo>()
|
||||
.eq(InvoiceInfo::getSoftDelete, 0)
|
||||
.eq(InvoiceInfo::getCustomerId, customerId)
|
||||
.eq(InvoiceInfo::getType, type)
|
||||
.orderByDesc(InvoiceInfo::getDefaultFlag)
|
||||
.orderByDesc(InvoiceInfo::getModifyTime));
|
||||
List<Map<String, Object>> rows = new ArrayList<>();
|
||||
for (InvoiceInfo invoice : invoices) {
|
||||
Map<String, Object> row = new LinkedHashMap<>();
|
||||
row.put("id", invoice.getId());
|
||||
row.put("invoiceName", invoice.getInvoiceName());
|
||||
row.put("invoiceType", invoice.getInvoiceType());
|
||||
row.put("identificationNumber", invoice.getIdentificationNumber());
|
||||
row.put("accountName", invoice.getAccountName());
|
||||
row.put("accountNo", invoice.getAccountNo());
|
||||
row.put("accountBank", invoice.getAccountBank());
|
||||
row.put("invoiceAddress", invoice.getInvoiceAddress());
|
||||
row.put("invoiceContact", invoice.getInvoiceContact());
|
||||
row.put("contact", invoice.getContact());
|
||||
row.put("mail", invoice.getMail());
|
||||
row.put("defaultFlag", invoice.getDefaultFlag());
|
||||
row.put("memo", invoice.getMemo());
|
||||
rows.add(row);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import me.iiv.agent.entity.m0.Agent;
|
||||
import me.iiv.agent.entity.m0.Properyt;
|
||||
import me.iiv.agent.entity.m0.User;
|
||||
import me.iiv.agent.mapper.m0.AgentMapper;
|
||||
import me.iiv.agent.mapper.m0.InvoiceInfoMapper;
|
||||
import me.iiv.agent.mapper.m0.ProperytMapper;
|
||||
import me.iiv.agent.mapper.m0.UserMapper;
|
||||
import me.iiv.agent.mcp.ToolObject;
|
||||
@@ -37,13 +38,16 @@ public class PropertyTools implements ToolObject {
|
||||
final ProperytMapper properytMapper;
|
||||
final AgentMapper agentMapper;
|
||||
final UserMapper userMapper;
|
||||
final InvoiceInfoMapper invoiceInfoMapper;
|
||||
final PermissionService permissionService;
|
||||
|
||||
public PropertyTools(ProperytMapper properytMapper, AgentMapper agentMapper,
|
||||
UserMapper userMapper, PermissionService permissionService) {
|
||||
UserMapper userMapper, InvoiceInfoMapper invoiceInfoMapper,
|
||||
PermissionService permissionService) {
|
||||
this.properytMapper = properytMapper;
|
||||
this.agentMapper = agentMapper;
|
||||
this.userMapper = userMapper;
|
||||
this.invoiceInfoMapper = invoiceInfoMapper;
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
@@ -149,4 +153,73 @@ public class PropertyTools implements ToolObject {
|
||||
result.put("records", records);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物业详情(含发票信息)。行权限:列表过滤语义 + 精确 id 叠加,
|
||||
* 代理商/销售只见其有权限的物业,总部不限。
|
||||
* invoices 来自 m0.invoice_info(type=1 + customer_id=id),含该物业名下全部抬头。
|
||||
*/
|
||||
@XqTool(category = "customer", kind = "read")
|
||||
@Tool(name = "property.detail.query", description = "查询物业(客户)详情(含发票信息),数据来源 m0 库 properyt 表。"
|
||||
+ "行级权限与 property.list.query 一致:代理商身份只能查 自己+直属下级代理+被授权代管代理 名下或被授权代管的物业;"
|
||||
+ "销售部门非负责人只能查自己创建的及被授权代管代理名下的物业;总部身份可查任意合法 id。"
|
||||
+ "返回 record(物业基础信息 + 默认发票镜像字段)和 invoices(该物业名下全部发票抬头,defaultFlag=1 为默认抬头,按默认优先+修改时间倒序)。"
|
||||
+ "invoiceType 含义:0=企业单位 1=个人|非企业。id 不存在或无权限时 record 为 null 并在 notice 字段说明。")
|
||||
public Map<String, Object> propertyDetailQuery(
|
||||
@ToolParam(required = true, description = "物业 id;仅可查有行级权限的物业") Long id) {
|
||||
User user = AuthContextHolder.get().getUser();
|
||||
LambdaQueryWrapper<Properyt> wrapper = new LambdaQueryWrapper<Properyt>()
|
||||
.eq(Properyt::getSoftDelete, 0)
|
||||
.eq(Properyt::getId, id);
|
||||
permissionService.applyPropertyRowFilter(wrapper, user);
|
||||
Properyt properyt = properytMapper.selectOne(wrapper);
|
||||
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
if (properyt == null) {
|
||||
result.put("record", null);
|
||||
result.put("invoices", List.of());
|
||||
result.put("notice", "id=" + id + " 不存在或当前身份无权查看");
|
||||
return result;
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Map<String, Object> record = new LinkedHashMap<>();
|
||||
record.put("id", properyt.getId());
|
||||
record.put("name", properyt.getName());
|
||||
record.put("serialnumber", properyt.getSerialnumber());
|
||||
record.put("agentName", resolveAgentName(properyt));
|
||||
record.put("province", properyt.getProvince());
|
||||
record.put("city", properyt.getCity());
|
||||
record.put("countyseat", properyt.getCountyseat());
|
||||
record.put("address", properyt.getAddress());
|
||||
record.put("contact", properyt.getContact());
|
||||
record.put("phone", properyt.getPhone());
|
||||
record.put("mail", properyt.getMail());
|
||||
record.put("memo", properyt.getMemo());
|
||||
record.put("districtOnCount", properyt.getDistrictOnCount());
|
||||
record.put("hardOnCount", properyt.getHardOnCount());
|
||||
record.put("userCount", properyt.getUserCount());
|
||||
record.put("createTime", properyt.getCreateTime() == null ? null : sdf.format(properyt.getCreateTime()));
|
||||
// 默认发票镜像字段(与 invoice_info 中 default_flag=1 的抬头同步)
|
||||
record.put("invoiceName", properyt.getInvoiceName());
|
||||
record.put("invoiceType", properyt.getInvoiceType());
|
||||
record.put("identificationNumber", properyt.getIdentificationNumber());
|
||||
record.put("accountName", properyt.getAccountName());
|
||||
record.put("accountNo", properyt.getAccountNo());
|
||||
record.put("accountBank", properyt.getAccountBank());
|
||||
record.put("invoiceAddress", properyt.getInvoiceAddress());
|
||||
record.put("invoiceContact", properyt.getInvoiceContact());
|
||||
record.put("lastInvoiceTime", properyt.getLastInvoiceTime() == null ? null : sdf.format(properyt.getLastInvoiceTime()));
|
||||
result.put("record", record);
|
||||
result.put("invoices", InvoiceQueries.query(invoiceInfoMapper, id, 1));
|
||||
return result;
|
||||
}
|
||||
|
||||
private String resolveAgentName(Properyt properyt) {
|
||||
if (properyt.getAgentId() == null) {
|
||||
return "未查询到";
|
||||
}
|
||||
Agent agent = agentMapper.selectById(properyt.getAgentId());
|
||||
return agent == null ? "未查询到" : agent.getName();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user