Compare commits

..

16 Commits

Author SHA1 Message Date
9c929301b9 feat(credit): 添加客户跟进七步骤功能
- 在CreditMpCustomer实体类中添加七个跟进步骤相关字段
- 实现跟进步骤审核功能,包括单个和批量审核接口
- 添加待审核步骤查询接口和客户跟进统计功能
- 实现流程结束功能和详细的步骤状态管理
- 创建相应的DTO和VO数据传输对象
- 在Mapper层添加待审核步骤查询SQL实现
2026-03-22 22:32:02 +08:00
ddebb6f16c feat(order): 添加配送员端可接单查询接口并修复权限控制
- 新增 /rider/available 接口供配送员查询可接单的送水订单
- 实现未分配订单查询逻辑(riderId 为 null 或 0 的订单)
- 修复配送员端订单查询权限控制,确保只能查看分配给自己的订单
- 优化 SQL 查询条件,支持通过 riderId 参数灵活控制订单分配状态筛选
- 添加配送员身份验证和租户隔离机制
- 设置配送员端默认排序规则为按期望配送时间优先
2026-03-22 09:48:38 +08:00
aea60e330d feat(entity): 添加客户实体真实姓名字段
- 在CreditMpCustomer实体中新增realName属性
- 为realName字段添加Schema注解描述
- 在关联查询SQL中加入real_name字段映射
- 更新表字段映射配置支持新字段
2026-03-19 17:37:21 +08:00
77a276e643 feat(credit): 添加客户流程步骤字段支持
- 在CreditMpCustomer实体中新增step字段用于跟踪客户流程步骤
- 更新status字段描述从"0正常, 1冻结"改为"0未受理, 1已受理"
- 在CreditMpCustomerMapper.xml中添加step查询条件支持
- 在CreditMpCustomerParam参数类中添加step查询字段
- 定义步骤状态:0未受理1已受理2材料提交3合同签订4执行回款5完结
2026-03-19 16:13:03 +08:00
3b723a74c6 perf(database): 优化数据库配置和用户查询性能
- 更新 Redis 配置为本地 1Panel 实例
- 为 UserMapper 查询添加 LIMIT 1 限制
- 为 credit_user 表创建多个复合索引以提升查询效率
- 添加租户、公司、用户维度的索引支持
- 优化默认分页排序的索引覆盖
- 包含统计关联数的索引优化
2026-03-19 00:00:45 +08:00
6a48722b67 fix(database): 修复用户角色查询中的表名引用问题
- 修正了 UserMapper.xml 中 sys_user_role 表的数据库模式前缀
- 添加了正确的 gxwebsoft_core 模式前缀以确保跨数据库兼容性
- 解决了由于表名解析错误可能导致的查询失败问题
2026-03-18 10:57:02 +08:00
ced6178271 feat(wx-login): 更新微信登录配置和优化access_token管理
- 修改application.yml中的激活环境从glt2到ysb2
- 在CreditMpCustomerMapper.xml中增加to_user字段的关键词搜索功能
- 删除WxLoginController中重复的TimeUnit导入
- 实现access_token失效时的自动刷新重试机制
- 使用微信稳定的stable_token接口替代原有token接口
- 添加强制刷新access_token的功能支持
- 优化缓存TTL计算逻辑,确保token在过期前及时刷新
- 改进微信API错误处理和异常信息提示
2026-03-18 10:43:10 +08:00
5775ad862d config(env): 更新环境配置和数据库连接信息
- 将默认激活环境从 ysb2 切换到 glt2
- 更新 glt2 环境的数据源配置,包括数据库名称、用户名和密码
- 修改 glt3 环境的 Redis 配置,更新数据库编号、主机地址、端口和密码
- 将微信登录控制器中的默认租户ID从 10550 更改为 10584
2026-03-17 11:03:14 +08:00
04d82682de fix(database): 修复客户表与用户表关联查询的字段映射错误
- 修正了 LEFT JOIN 条件中的字段引用错误
- 将 u.id = a.user_id 更改为 u.user_id = a.user_id
- 确保了用户信息能够正确关联到客户记录上
2026-03-16 23:36:48 +08:00
41fb24b9ff feat(customer): 添加客户实体用户关联字段支持
- 修改application.yml配置文件激活环境从glt2切换到ysb2
- 在CreditMpCustomer实体类中新增nickname、phone、avatar三个关联字段
- 为新增字段添加TableField注解标记为非数据库字段
- 更新CreditMpCustomerMapper.xml中的关联查询SQL
- 添加LEFT JOIN子句关联sys_user表获取用户信息
- 查询结果中包含用户昵称、头像、手机号等扩展信息
2026-03-16 22:32:30 +08:00
044d87cfde feat(credit): 新增小程序端客户管理功能
- 修改Redis数据库配置从database 0切换到database 3
- 添加代码生成工具YsbGenerator用于自动生成CRUD代码
- 生成CreditMpCustomer实体类包含客户基本信息和状态字段
- 创建CreditMpCustomerController提供RESTful API接口
- 实现CreditMpCustomerService业务逻辑层
- 添加CreditMpCustomerMapper数据访问层及XML映射文件
- 生成CreditMpCustomerParam查询参数类支持条件筛选
- 实现服务层接口及具体业务逻辑方法
- 集成权限控制和操作日志记录功能
- 支持分页查询、批量操作和关联查询功能
2026-03-16 21:14:36 +08:00
7fe347d7bc feat(shop): 更新数据库配置并添加订单状态关联查询
- 修改 application-glt2.yml 中的数据源配置,将数据库从 modules 更改为 gltdb
- 修改 application-glt3.yml 中的数据源配置,将数据库从 modules 更改为 gltdb
- 在 ShopDealerCapital 实体类中添加 orderStatus 字段用于存储订单状态
- 更新 ShopDealerCapitalMapper.xml 查询语句,关联 shop_order 表获取订单状态
- 添加 LEFT JOIN 条件连接 shop_order 表以获取订单状态信息
2026-03-16 13:10:26 +08:00
3f546f7e70 feat(shop): 更新数据库配置并添加订单状态关联查询
- 修改 application-glt2.yml 中的数据源配置,将数据库从 modules 更改为 gltdb
- 修改 application-glt3.yml 中的数据源配置,将数据库从 modules 更改为 gltdb
- 在 ShopDealerCapital 实体类中添加 orderStatus 字段用于存储订单状态
- 更新 ShopDealerCapitalMapper.xml 查询语句,关联 shop_order 表获取订单状态
- 添加 LEFT JOIN 条件连接 shop_order 表以获取订单状态信息
2026-03-16 12:50:52 +08:00
896491fa0b Merge remote-tracking branch 'origin/master' 2026-03-16 00:21:11 +08:00
9c85223545 feat(order): 更新订单修改功能并添加新环境配置
- 修改 application.yml 默认激活环境从 ysb2 到 glt2
- 新增 application-glt3.yml 环境配置文件,包含服务器、数据源、Redis等完整配置
- 在订单更新接口中添加地址同步逻辑,支持根据 addressId 更新订单地址快照
- 添加订单更新时的参数验证和权限检查机制
- 在订单模板实体中新增步长字段用于业务配置
- 优化订单更新流程中的租户和用户权限验证逻辑
2026-03-16 00:21:05 +08:00
f783aaa242 feat(entity): 添加企业别名字段到多个实体类
- 在 CreditAdministrativeLicense 实体中添加 companyAlias 字段
- 在 CreditBranch 实体中添加 companyAlias 字段
- 在 CreditCompetitor 实体中添加 companyAlias 字段
- 在 CreditCustomer 实体中添加 companyAlias 字段
- 在 CreditExternal 实体中添加 companyAlias 字段
- 在 CreditHistoricalLegalPerson 实体中添加 companyAlias 字段
- 在 CreditNearbyCompany 实体中添加 companyAlias 字段
- 在 CreditRiskRelation 实体中添加 companyAlias 字段
- 在 CreditSupplier 实体中添加 companyAlias 字段
- 在 CreditSuspectedRelationship 实体中添加 companyAlias 字段
- 在 CreditUser 实体中添加 companyAlias 字段
2026-03-15 14:06:31 +08:00
40 changed files with 2767 additions and 64 deletions

View File

@@ -0,0 +1,458 @@
# 客户跟进7步骤后端实现指南
## 📋 概述
本指南详细说明如何实现客户跟进7个步骤功能的后端代码包括数据库设计、Java后端实现和API接口。
## 🗄️ 数据库设计
### 1. 修改 credit_mp_customer 表结构
```sql
-- 为第5-7步添加字段第1-4步字段已存在
-- 第5步合同签订
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_submitted TINYINT DEFAULT 0 COMMENT '是否已提交';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_submitted_at VARCHAR(255) COMMENT '提交时间';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_contracts TEXT COMMENT '合同信息JSON数组';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_need_approval TINYINT DEFAULT 1 COMMENT '是否需要审核';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_approved TINYINT DEFAULT 0 COMMENT '是否审核通过';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_approved_at VARCHAR(255) COMMENT '审核时间';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step5_approved_by BIGINT COMMENT '审核人ID';
-- 第6步订单回款
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_submitted TINYINT DEFAULT 0 COMMENT '是否已提交';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_submitted_at VARCHAR(255) COMMENT '提交时间';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_payment_records TEXT COMMENT '财务录入的回款记录JSON数组';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_expected_payments TEXT COMMENT '预计回款JSON数组';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_need_approval TINYINT DEFAULT 1 COMMENT '是否需要审核';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_approved TINYINT DEFAULT 0 COMMENT '是否审核通过';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_approved_at VARCHAR(255) COMMENT '审核时间';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step6_approved_by BIGINT COMMENT '审核人ID';
-- 第7步电话回访
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_submitted TINYINT DEFAULT 0 COMMENT '是否已提交';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_submitted_at VARCHAR(255) COMMENT '提交时间';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_visit_records TEXT COMMENT '回访记录JSON数组';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_need_approval TINYINT DEFAULT 1 COMMENT '是否需要审核';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_approved TINYINT DEFAULT 0 COMMENT '是否审核通过';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_approved_at VARCHAR(255) COMMENT '审核时间';
ALTER TABLE credit_mp_customer ADD COLUMN follow_step7_approved_by BIGINT COMMENT '审核人ID';
-- 添加流程结束相关字段
ALTER TABLE credit_mp_customer ADD COLUMN follow_process_ended TINYINT DEFAULT 0 COMMENT '流程是否已结束';
ALTER TABLE credit_mp_customer ADD COLUMN follow_process_end_time VARCHAR(255) COMMENT '流程结束时间';
ALTER TABLE credit_mp_customer ADD COLUMN follow_process_end_reason TEXT COMMENT '流程结束原因';
```
### 2. 创建审核记录表(可选)
```sql
CREATE TABLE credit_follow_approval (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
customer_id BIGINT NOT NULL COMMENT '客户ID',
step TINYINT NOT NULL COMMENT '步骤号',
approved TINYINT NOT NULL COMMENT '是否通过',
remark TEXT COMMENT '审核备注',
approved_by BIGINT COMMENT '审核人ID',
approved_at VARCHAR(255) COMMENT '审核时间',
created_at VARCHAR(255) COMMENT '创建时间',
INDEX idx_customer_step (customer_id, step),
INDEX idx_approved_by (approved_by)
) COMMENT='跟进步骤审核记录';
```
## ☕ Java后端实现
### 1. 实体类修改
```java
// CreditMpCustomer.java 添加字段
public class CreditMpCustomer {
// ... 现有字段
// 第5步字段
private Integer followStep5Submitted;
private String followStep5SubmittedAt;
private String followStep5Contracts;
private Integer followStep5NeedApproval;
private Integer followStep5Approved;
private String followStep5ApprovedAt;
private Long followStep5ApprovedBy;
// 第6步字段
private Integer followStep6Submitted;
private String followStep6SubmittedAt;
private String followStep6PaymentRecords;
private String followStep6ExpectedPayments;
private Integer followStep6NeedApproval;
private Integer followStep6Approved;
private String followStep6ApprovedAt;
private Long followStep6ApprovedBy;
// 第7步字段
private Integer followStep7Submitted;
private String followStep7SubmittedAt;
private String followStep7VisitRecords;
private Integer followStep7NeedApproval;
private Integer followStep7Approved;
private String followStep7ApprovedAt;
private Long followStep7ApprovedBy;
// 流程结束字段
private Integer followProcessEnded;
private String followProcessEndTime;
private String followProcessEndReason;
// getter/setter 方法...
}
```
### 2. DTO类创建
```java
// FollowStepApprovalDTO.java
@Data
public class FollowStepApprovalDTO {
private Long customerId;
private Integer step;
private Boolean approved;
private String remark;
}
// BatchFollowStepApprovalDTO.java
@Data
public class BatchFollowStepApprovalDTO {
private List<FollowStepApprovalDTO> approvals;
}
// FollowStatisticsDTO.java
@Data
public class FollowStatisticsDTO {
private Integer totalSteps;
private Integer completedSteps;
private Integer currentStep;
private Double progress;
private List<FollowStepDetailDTO> stepDetails;
}
// FollowStepDetailDTO.java
@Data
public class FollowStepDetailDTO {
private Integer step;
private String title;
private String status; // pending, submitted, approved, rejected
private String submittedAt;
private String approvedAt;
}
```
### 3. Service层实现
```java
// CreditMpCustomerServiceImpl.java 添加方法
@Service
public class CreditMpCustomerServiceImpl implements CreditMpCustomerService {
/**
* 审核跟进步骤
*/
@Override
@Transactional
public void approveFollowStep(FollowStepApprovalDTO dto) {
CreditMpCustomer customer = getById(dto.getCustomerId());
if (customer == null) {
throw new ServiceException("客户不存在");
}
// 验证步骤是否已提交
if (!isStepSubmitted(customer, dto.getStep())) {
throw new ServiceException("该步骤尚未提交,无法审核");
}
// 更新审核状态
updateStepApproval(customer, dto);
// 记录审核日志
saveApprovalLog(dto);
// 如果审核通过,更新客户步骤状态
if (dto.getApproved()) {
updateCustomerStep(customer, dto.getStep());
}
}
/**
* 批量审核跟进步骤
*/
@Override
@Transactional
public void batchApproveFollowSteps(BatchFollowStepApprovalDTO dto) {
for (FollowStepApprovalDTO approval : dto.getApprovals()) {
approveFollowStep(approval);
}
}
/**
* 获取待审核的跟进步骤列表
*/
@Override
public List<PendingApprovalStepVO> getPendingApprovalSteps(FollowStepQueryDTO query) {
return baseMapper.selectPendingApprovalSteps(query);
}
/**
* 获取客户跟进统计
*/
@Override
public FollowStatisticsDTO getFollowStatistics(Long customerId) {
CreditMpCustomer customer = getById(customerId);
if (customer == null) {
throw new ServiceException("客户不存在");
}
FollowStatisticsDTO statistics = new FollowStatisticsDTO();
statistics.setTotalSteps(7);
List<FollowStepDetailDTO> stepDetails = new ArrayList<>();
int completedSteps = 0;
int currentStep = 1;
for (int i = 1; i <= 7; i++) {
FollowStepDetailDTO detail = getStepDetail(customer, i);
stepDetails.add(detail);
if ("approved".equals(detail.getStatus())) {
completedSteps++;
currentStep = i + 1;
} else if ("submitted".equals(detail.getStatus()) && currentStep == 1) {
currentStep = i;
}
}
statistics.setCompletedSteps(completedSteps);
statistics.setCurrentStep(Math.min(currentStep, 7));
statistics.setProgress((double) completedSteps / 7 * 100);
statistics.setStepDetails(stepDetails);
return statistics;
}
/**
* 结束客户跟进流程
*/
@Override
@Transactional
public void endFollowProcess(Long customerId, String reason) {
CreditMpCustomer customer = getById(customerId);
if (customer == null) {
throw new ServiceException("客户不存在");
}
customer.setFollowProcessEnded(1);
customer.setFollowProcessEndTime(DateUtil.formatDateTime(new Date()));
customer.setFollowProcessEndReason(reason);
updateById(customer);
}
// 私有辅助方法...
private boolean isStepSubmitted(CreditMpCustomer customer, Integer step) {
switch (step) {
case 1: return customer.getFollowStep1Submitted() == 1;
case 2: return customer.getFollowStep2Submitted() == 1;
// ... 其他步骤
case 7: return customer.getFollowStep7Submitted() == 1;
default: return false;
}
}
private void updateStepApproval(CreditMpCustomer customer, FollowStepApprovalDTO dto) {
String currentTime = DateUtil.formatDateTime(new Date());
Long currentUserId = SecurityFrameworkUtils.getLoginUserId();
switch (dto.getStep()) {
case 5:
customer.setFollowStep5Approved(dto.getApproved() ? 1 : 0);
customer.setFollowStep5ApprovedAt(currentTime);
customer.setFollowStep5ApprovedBy(currentUserId);
break;
case 6:
customer.setFollowStep6Approved(dto.getApproved() ? 1 : 0);
customer.setFollowStep6ApprovedAt(currentTime);
customer.setFollowStep6ApprovedBy(currentUserId);
break;
case 7:
customer.setFollowStep7Approved(dto.getApproved() ? 1 : 0);
customer.setFollowStep7ApprovedAt(currentTime);
customer.setFollowStep7ApprovedBy(currentUserId);
break;
}
updateById(customer);
}
}
```
### 4. Controller层实现
```java
// CreditMpCustomerController.java 添加接口
@RestController
@RequestMapping("/credit/credit-mp-customer")
public class CreditMpCustomerController {
@PostMapping("/approve-follow-step")
@OperLog(title = "审核跟进步骤", businessType = BusinessType.UPDATE)
public R<Void> approveFollowStep(@RequestBody FollowStepApprovalDTO dto) {
creditMpCustomerService.approveFollowStep(dto);
return R.ok();
}
@PostMapping("/batch-approve-follow-steps")
@OperLog(title = "批量审核跟进步骤", businessType = BusinessType.UPDATE)
public R<Void> batchApproveFollowSteps(@RequestBody BatchFollowStepApprovalDTO dto) {
creditMpCustomerService.batchApproveFollowSteps(dto);
return R.ok();
}
@GetMapping("/pending-approval-steps")
@OperLog(title = "获取待审核跟进步骤", businessType = BusinessType.SELECT)
public R<List<PendingApprovalStepVO>> getPendingApprovalSteps(FollowStepQueryDTO query) {
List<PendingApprovalStepVO> list = creditMpCustomerService.getPendingApprovalSteps(query);
return R.ok(list);
}
@GetMapping("/follow-statistics/{customerId}")
@OperLog(title = "获取客户跟进统计", businessType = BusinessType.SELECT)
public R<FollowStatisticsDTO> getFollowStatistics(@PathVariable Long customerId) {
FollowStatisticsDTO statistics = creditMpCustomerService.getFollowStatistics(customerId);
return R.ok(statistics);
}
@PostMapping("/end-follow-process")
@OperLog(title = "结束客户跟进流程", businessType = BusinessType.UPDATE)
public R<Void> endFollowProcess(@RequestBody EndFollowProcessDTO dto) {
creditMpCustomerService.endFollowProcess(dto.getCustomerId(), dto.getReason());
return R.ok();
}
}
```
### 5. Mapper层SQL
```xml
<!-- CreditMpCustomerMapper.xml 添加查询方法 -->
<select id="selectPendingApprovalSteps" resultType="com.your.package.PendingApprovalStepVO">
SELECT
c.id as customerId,
c.to_user as customerName,
5 as step,
'合同签订' as stepTitle,
c.follow_step5_submitted_at as submittedAt,
u.real_name as submittedBy,
c.follow_step5_contracts as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step5_submitted = 1
AND c.follow_step5_approved = 0
AND c.deleted = 0
UNION ALL
SELECT
c.id as customerId,
c.to_user as customerName,
6 as step,
'订单回款' as stepTitle,
c.follow_step6_submitted_at as submittedAt,
u.real_name as submittedBy,
c.follow_step6_expected_payments as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step6_submitted = 1
AND c.follow_step6_approved = 0
AND c.deleted = 0
UNION ALL
SELECT
c.id as customerId,
c.to_user as customerName,
7 as step,
'电话回访' as stepTitle,
c.follow_step7_submitted_at as submittedAt,
u.real_name as submittedBy,
c.follow_step7_visit_records as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step7_submitted = 1
AND c.follow_step7_approved = 0
AND c.deleted = 0
<if test="step != null">
HAVING step = #{step}
</if>
<if test="customerId != null">
HAVING customerId = #{customerId}
</if>
ORDER BY submittedAt DESC
</select>
```
## 🔧 业务逻辑说明
### 1. 步骤解锁机制
- 第一步始终可用
- 后续步骤需要前一步审核通过才能进行
- 前端通过 `canEnterStep` 逻辑控制
### 2. 审核流程
- 步骤提交后设置 `needApproval = 1`
- 管理员在后台审核
- 审核通过后设置 `approved = 1` 并更新时间
### 3. 数据格式
- 所有复杂数据使用JSON格式存储
- 文件上传返回URL存储在JSON数组中
- 时间统一使用 `YYYY-MM-DD HH:mm:ss` 格式
### 4. 权限控制
- 销售只能提交和查看自己的客户
- 管理员可以审核所有步骤
- 财务人员可以录入第6步回款数据
## 📱 前端集成
前端代码已经完成,包括:
- 7个步骤的完整页面
- 步骤状态显示和跳转逻辑
- 数据提交和验证
- 客户详情页面的汇总显示
## 🚀 部署步骤
1. 执行数据库迁移脚本
2. 部署Java后端代码
3. 更新前端API调用
4. 测试完整流程
5. 配置权限和审核流程
## 📝 注意事项
1. **数据备份**:执行数据库变更前请备份
2. **权限配置**:确保各角色权限正确配置
3. **文件上传**:确认文件上传服务正常
4. **审核流程**:测试审核流程的完整性
5. **性能优化**:大量数据时考虑分页和索引优化
## 🔄 后续扩展
可以考虑的功能:
- 跟进模板和标准化流程
- 自动提醒和通知
- 数据统计和报表
- 跟进效率分析
- 客户满意度评估

View File

@@ -0,0 +1,34 @@
-- credit_user 索引优化MySQL/InnoDB
--
-- 背景:
-- - credit_user 列表分页默认排序sort_number asc, create_time desc
-- - 常见过滤tenant_idTenantLine 自动追加、deleted=0、company_id、user_id、create_time 范围
-- - 统计/刷新关联数WHERE deleted=0 AND company_id IN (...) GROUP BY company_id
--
-- 使用前建议先查看现有索引,避免重复:
-- SHOW INDEX FROM credit_user;
--
-- 注意:
-- - 大表加索引会消耗 IO/CPU建议在低峰执行。
-- - MySQL 8 可考虑ALTER TABLE ... ALGORITHM=INPLACE, LOCK=NONE视版本/引擎而定)。
-- 1) 覆盖默认分页排序 + 逻辑删除 + 租户隔离
-- 典型WHERE tenant_id=? AND deleted=0 ORDER BY sort_number, create_time DESC LIMIT ...
CREATE INDEX idx_credit_user_tenant_deleted_sort_create_id
ON credit_user (tenant_id, deleted, sort_number, create_time, id);
-- 2) 企业维度查询/统计(也服务于 credit_company 记录数刷新)
-- 典型WHERE tenant_id=? AND company_id=? AND deleted=0 ...
-- 典型WHERE tenant_id=? AND deleted=0 AND company_id IN (...) GROUP BY company_id
CREATE INDEX idx_credit_user_tenant_company_deleted
ON credit_user (tenant_id, company_id, deleted);
-- 3) 用户维度查询(后台常按录入人/负责人筛选)
-- 典型WHERE tenant_id=? AND user_id=? AND deleted=0 ...
CREATE INDEX idx_credit_user_tenant_user_deleted
ON credit_user (tenant_id, user_id, deleted);
-- 可选:如果你们经常按 type 过滤0/1再加这个否则先别加避免过多索引影响写入
-- CREATE INDEX idx_credit_user_tenant_type_deleted
-- ON credit_user (tenant_id, type, deleted);

View File

@@ -42,7 +42,6 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import static com.gxwebsoft.common.core.constants.PlatformConstants.MP_WEIXIN;
import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KEY;
@@ -246,27 +245,30 @@ public class WxLoginController extends BaseController {
* @param userParam 需要传微信凭证code
*/
private String getPhoneByCode(UserParam userParam) {
// 获取手机号码
String apiUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + getAccessToken();
HashMap<String, Object> paramMap = new HashMap<>();
if (StrUtil.isBlank(userParam.getCode())) {
throw new BusinessException("code不能为空");
}
paramMap.put("code", userParam.getCode());
// 执行post请求
String post = HttpUtil.post(apiUrl, JSON.toJSONString(paramMap));
JSONObject json = JSON.parseObject(post);
if (json.get("errcode").equals(0)) {
JSONObject phoneInfo = JSON.parseObject(json.getString("phone_info"));
// 微信用户的手机号码
final String phoneNumber = phoneInfo.getString("phoneNumber");
// 验证手机号码
// if (userParam.getNotVerifyPhone() == null && !Validator.isMobile(phoneNumber)) {
// String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString());
// redisTemplate.delete(key);
// throw new BusinessException("手机号码格式不正确");
// }
return phoneNumber;
// access_token 失效/过期时自动刷新并重试一次
for (int attempt = 0; attempt < 2; attempt++) {
String accessToken = (attempt == 0) ? getAccessToken(false) : getAccessToken(true);
String apiUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken;
String post = HttpUtil.post(apiUrl, JSON.toJSONString(paramMap));
JSONObject json = JSON.parseObject(post);
Integer errcode = json.getInteger("errcode");
if (errcode != null && errcode.equals(0)) {
JSONObject phoneInfo = JSON.parseObject(json.getString("phone_info"));
return phoneInfo.getString("phoneNumber");
}
if (errcode != null && (errcode == 40001 || errcode == 42001 || errcode == 40014)) {
continue;
}
return null;
}
return null;
}
@@ -285,6 +287,10 @@ public class WxLoginController extends BaseController {
* <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html">...</a>
*/
public String getAccessToken() {
return getAccessToken(false);
}
private String getAccessToken(boolean forceRefresh) {
Integer tenantId = getTenantId();
String key = ACCESS_TOKEN_KEY.concat(":").concat(tenantId.toString());
@@ -294,9 +300,13 @@ public class WxLoginController extends BaseController {
throw new BusinessException("请先配置小程序");
}
if (forceRefresh) {
redisTemplate.delete(key);
}
// 从缓存获取access_token
String value = redisTemplate.opsForValue().get(key);
if (value != null) {
if (!forceRefresh && value != null) {
// 解析access_token
JSONObject response = JSON.parseObject(value);
String accessToken = response.getString("access_token");
@@ -305,23 +315,38 @@ public class WxLoginController extends BaseController {
}
}
// 微信获取凭证接口
String apiUrl = "https://api.weixin.qq.com/cgi-bin/token";
// 组装url参数
String url = apiUrl.concat("?grant_type=client_credential")
.concat("&appid=").concat(setting.getString("appId"))
.concat("&secret=").concat(setting.getString("appSecret"));
String appId = setting.getString("appId");
String appSecret = setting.getString("appSecret");
// 执行get请求
String result = HttpUtil.get(url);
// 解析access_token
// 微信稳定版获取凭证接口避免并发刷新导致旧token失效
String apiUrl = "https://api.weixin.qq.com/cgi-bin/stable_token";
JSONObject reqBody = new JSONObject();
reqBody.put("grant_type", "client_credential");
reqBody.put("appid", appId);
reqBody.put("secret", appSecret);
reqBody.put("force_refresh", forceRefresh);
String result = HttpRequest.post(apiUrl)
.header("Content-Type", "application/json")
.body(reqBody.toJSONString())
.execute()
.body();
JSONObject response = JSON.parseObject(result);
if (response.getString("access_token") != null) {
// 存入缓存
redisTemplate.opsForValue().set(key, result, 7000L, TimeUnit.SECONDS);
return response.getString("access_token");
Integer errcode = response.getInteger("errcode");
if (errcode != null && errcode != 0) {
throw new BusinessException("获取access_token失败: " + response.getString("errmsg") + " (errcode: " + errcode + ")");
}
throw new BusinessException("小程序配置不正确");
String accessToken = response.getString("access_token");
Integer expiresIn = response.getInteger("expires_in");
if (accessToken != null) {
long ttlSeconds = Math.max((expiresIn != null ? expiresIn : 7200) - 300L, 60L);
redisTemplate.opsForValue().set(key, result, ttlSeconds, TimeUnit.SECONDS);
return accessToken;
}
throw new BusinessException("获取access_token失败: " + result);
}
@Operation(summary = "获取微信openId并更新")
@@ -576,23 +601,29 @@ public class WxLoginController extends BaseController {
throw new IOException("小程序配置不完整,缺少 appId 或 appSecret");
}
HttpUrl url = HttpUrl.parse("https://api.weixin.qq.com/cgi-bin/token")
.newBuilder()
.addQueryParameter("grant_type", "client_credential")
.addQueryParameter("appid", appId)
.addQueryParameter("secret", appSecret)
.build();
HttpUrl url = HttpUrl.parse("https://api.weixin.qq.com/cgi-bin/stable_token").newBuilder().build();
var root = om.createObjectNode();
root.put("grant_type", "client_credential");
root.put("appid", appId);
root.put("secret", appSecret);
root.put("force_refresh", false);
Request req = new Request.Builder().url(url).get().build();
okhttp3.RequestBody reqBody = okhttp3.RequestBody.create(
root.toString(), MediaType.parse("application/json; charset=utf-8"));
Request req = new Request.Builder().url(url).post(reqBody).build();
try (Response resp = http.newCall(req).execute()) {
String body = resp.body().string();
JsonNode json = om.readTree(body);
if (json.has("errcode") && json.get("errcode").asInt() != 0) {
throw new IOException("Get access_token failed: " + body);
}
if (json.has("access_token")) {
String token = json.get("access_token").asText();
long expiresIn = json.get("expires_in").asInt(7200);
// 缓存完整的JSON响应与其他方法保持一致
redisUtil.set(key, body, expiresIn, TimeUnit.SECONDS);
long ttlSeconds = Math.max(expiresIn - 300L, 60L);
redisUtil.set(key, body, ttlSeconds, TimeUnit.SECONDS);
tokenExpireEpoch = now + expiresIn;
System.out.println("获取新的access_token成功(Local)租户ID: " + tenantId);
return token;
@@ -686,7 +717,7 @@ public class WxLoginController extends BaseController {
// 获取当前线程的租户ID
Integer tenantId = getTenantId();
if (tenantId == null) {
tenantId = 10550; // 默认租户
tenantId = 10584; // 默认租户
}
System.out.println("=== 开始调试获取AccessToken租户ID: " + tenantId + " ===");
@@ -748,14 +779,14 @@ public class WxLoginController extends BaseController {
}
}
// 如果无法解析默认使用租户10550
System.out.println("无法解析scene参数使用默认租户ID: 10550");
return 10550;
// 如果无法解析默认使用租户10584
System.out.println("无法解析scene参数使用默认租户ID: 10584");
return 10584;
} catch (Exception e) {
System.err.println("解析scene参数异常: " + e.getMessage());
// 出现异常时默认使用租户10550
return 10550;
// 出现异常时默认使用租户10584
return 10584;
}
}
@@ -789,10 +820,21 @@ public class WxLoginController extends BaseController {
String appId = wxConfig.getString("appId");
String appSecret = wxConfig.getString("appSecret");
String apiUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
String apiUrl = "https://api.weixin.qq.com/cgi-bin/stable_token";
System.out.println("调用微信API获取token - 租户ID: " + tenantId + ", AppID: " + (appId != null ? appId.substring(0, Math.min(8, appId.length())) + "..." : "null"));
System.out.println("微信API请求URL: " + apiUrl.replaceAll("secret=[^&]*", "secret=***"));
String result = HttpUtil.get(apiUrl);
System.out.println("微信API请求URL: " + apiUrl);
JSONObject reqBody = new JSONObject();
reqBody.put("grant_type", "client_credential");
reqBody.put("appid", appId);
reqBody.put("secret", appSecret);
reqBody.put("force_refresh", false);
String result = HttpRequest.post(apiUrl)
.header("Content-Type", "application/json")
.body(reqBody.toJSONString())
.execute()
.body();
System.out.println("微信API响应: " + result);
JSONObject json = JSON.parseObject(result);
@@ -800,14 +842,15 @@ public class WxLoginController extends BaseController {
if (json.containsKey("errcode")) {
Integer errcode = json.getInteger("errcode");
String errmsg = json.getString("errmsg");
System.err.println("微信API错误 - errcode: " + errcode + ", errmsg: " + errmsg);
if (errcode == 40125) {
throw new RuntimeException("微信AppSecret配置错误请检查并更新正确的AppSecret");
} else if (errcode == 40013) {
throw new RuntimeException("微信AppID配置错误请检查并更新正确的AppID");
} else {
throw new RuntimeException("微信API调用失败: " + errmsg + " (errcode: " + errcode + ")");
if (errcode != null && errcode != 0) {
System.err.println("微信API错误 - errcode: " + errcode + ", errmsg: " + errmsg);
if (errcode == 40125) {
throw new RuntimeException("微信AppSecret配置错误请检查并更新正确的AppSecret");
} else if (errcode == 40013) {
throw new RuntimeException("微信AppID配置错误请检查并更新正确的AppID");
} else {
throw new RuntimeException("微信API调用失败: " + errmsg + " (errcode: " + errcode + ")");
}
}
}
@@ -816,7 +859,8 @@ public class WxLoginController extends BaseController {
Integer expiresIn = json.getInteger("expires_in");
// 缓存access_token存储完整JSON响应与getAccessToken方法保持一致
redisUtil.set(key, result, (long) (expiresIn - 300), TimeUnit.SECONDS);
long ttlSeconds = Math.max((expiresIn != null ? expiresIn : 7200) - 300L, 60L);
redisUtil.set(key, result, ttlSeconds, TimeUnit.SECONDS);
System.out.println("获取新的access_token成功租户ID: " + tenantId);
return accessToken;

View File

@@ -102,7 +102,7 @@
AND a.deleted = 0
</if>
<if test="param.roleId != null">
AND a.user_id IN (SELECT user_id FROM sys_user_role WHERE role_id=#{param.roleId})
AND a.user_id IN (SELECT user_id FROM gxwebsoft_core.sys_user_role WHERE role_id=#{param.roleId})
</if>
<if test="param.userIds != null">
AND a.user_id IN
@@ -259,6 +259,7 @@
LEFT JOIN gxwebsoft_core.sys_user_referee h ON a.user_id = h.user_id and h.deleted = 0
WHERE a.user_id = #{userId}
AND a.deleted = 0
LIMIT 1
</select>
</mapper>

View File

@@ -0,0 +1,178 @@
package com.gxwebsoft.credit.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.credit.service.CreditMpCustomerService;
import com.gxwebsoft.credit.entity.CreditMpCustomer;
import com.gxwebsoft.credit.param.CreditMpCustomerParam;
import com.gxwebsoft.credit.param.BatchFollowStepApprovalDTO;
import com.gxwebsoft.credit.param.EndFollowProcessDTO;
import com.gxwebsoft.credit.param.FollowStepApprovalDTO;
import com.gxwebsoft.credit.param.FollowStepQueryDTO;
import com.gxwebsoft.credit.vo.FollowStatisticsDTO;
import com.gxwebsoft.credit.vo.PendingApprovalStepVO;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 小程序端客户控制器
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
@Tag(name = "小程序端客户管理")
@RestController
@RequestMapping("/api/credit/credit-mp-customer")
public class CreditMpCustomerController extends BaseController {
@Resource
private CreditMpCustomerService creditMpCustomerService;
@PreAuthorize("hasAuthority('credit:creditMpCustomer:list')")
@Operation(summary = "分页查询小程序端客户")
@GetMapping("/page")
public ApiResult<PageResult<CreditMpCustomer>> page(CreditMpCustomerParam param) {
// 使用关联查询
return success(creditMpCustomerService.pageRel(param));
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:list')")
@Operation(summary = "查询全部小程序端客户")
@GetMapping()
public ApiResult<List<CreditMpCustomer>> list(CreditMpCustomerParam param) {
// 使用关联查询
return success(creditMpCustomerService.listRel(param));
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:list')")
@Operation(summary = "根据id查询小程序端客户")
@GetMapping("/{id}")
public ApiResult<CreditMpCustomer> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(creditMpCustomerService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:save')")
@OperationLog
@Operation(summary = "添加小程序端客户")
@PostMapping()
public ApiResult<?> save(@RequestBody CreditMpCustomer creditMpCustomer) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
creditMpCustomer.setUserId(loginUser.getUserId());
}
if (creditMpCustomerService.save(creditMpCustomer)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:update')")
@OperationLog
@Operation(summary = "修改小程序端客户")
@PutMapping()
public ApiResult<?> update(@RequestBody CreditMpCustomer creditMpCustomer) {
if (creditMpCustomerService.updateById(creditMpCustomer)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:remove')")
@OperationLog
@Operation(summary = "删除小程序端客户")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (creditMpCustomerService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:save')")
@OperationLog
@Operation(summary = "批量添加小程序端客户")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<CreditMpCustomer> list) {
if (creditMpCustomerService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:update')")
@OperationLog
@Operation(summary = "批量修改小程序端客户")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<CreditMpCustomer> batchParam) {
if (batchParam.update(creditMpCustomerService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:remove')")
@OperationLog
@Operation(summary = "批量删除小程序端客户")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (creditMpCustomerService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:update')")
@OperationLog
@Operation(summary = "审核跟进步骤")
@PostMapping("/approve-follow-step")
public ApiResult<?> approveFollowStep(@RequestBody FollowStepApprovalDTO dto) {
creditMpCustomerService.approveFollowStep(dto);
return success("审核成功");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:update')")
@OperationLog
@Operation(summary = "批量审核跟进步骤")
@PostMapping("/batch-approve-follow-steps")
public ApiResult<?> batchApproveFollowSteps(@RequestBody BatchFollowStepApprovalDTO dto) {
creditMpCustomerService.batchApproveFollowSteps(dto);
return success("批量审核成功");
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:list')")
@Operation(summary = "获取待审核的跟进步骤")
@GetMapping("/pending-approval-steps")
public ApiResult<List<PendingApprovalStepVO>> getPendingApprovalSteps(FollowStepQueryDTO query) {
List<PendingApprovalStepVO> list = creditMpCustomerService.getPendingApprovalSteps(query);
return success(list);
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:list')")
@Operation(summary = "获取客户跟进统计")
@GetMapping("/follow-statistics/{customerId}")
public ApiResult<FollowStatisticsDTO> getFollowStatistics(@PathVariable Long customerId) {
FollowStatisticsDTO statistics = creditMpCustomerService.getFollowStatistics(customerId);
return success(statistics);
}
@PreAuthorize("hasAuthority('credit:creditMpCustomer:update')")
@OperationLog
@Operation(summary = "结束客户跟进流程")
@PostMapping("/end-follow-process")
public ApiResult<?> endFollowProcess(@RequestBody EndFollowProcessDTO dto) {
creditMpCustomerService.endFollowProcess(dto);
return success("流程结束成功");
}
}

View File

@@ -71,6 +71,9 @@ public class CreditAdministrativeLicense implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "主体企业")
@TableField(exist = false)
private String companyName;

View File

@@ -55,6 +55,9 @@ public class CreditBranch implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "主题企业")
@TableField(exist = false)
private String companyName;

View File

@@ -57,6 +57,9 @@ public class CreditCompetitor implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "企业名称")
private String companyName;

View File

@@ -51,6 +51,9 @@ public class CreditCustomer implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "企业名称")
private String companyName;

View File

@@ -78,6 +78,9 @@ public class CreditExternal implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "企业名称")
private String companyName;

View File

@@ -49,6 +49,9 @@ public class CreditHistoricalLegalPerson implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "主体企业")
@TableField(exist = false)
private String companyName;

View File

@@ -0,0 +1,268 @@
package com.gxwebsoft.credit.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 小程序端客户
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "CreditMpCustomer对象", description = "小程序端客户")
public class CreditMpCustomer implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@Schema(description = "拖欠方")
private String toUser;
@Schema(description = "拖欠金额")
private String price;
@Schema(description = "拖欠年数")
private String years;
@Schema(description = "链接")
private String url;
@Schema(description = "状态")
private String statusTxt;
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "所在省份")
private String province;
@Schema(description = "所在城市")
private String city;
@Schema(description = "所在辖区")
private String region;
@Schema(description = "文件路径")
private String files;
@Schema(description = "是否有数据")
private Boolean hasData;
@Schema(description = "步骤, 0未受理1已受理2材料提交3合同签订4执行回款5完结")
private Integer step;
@Schema(description = "备注")
private String comments;
@Schema(description = "是否推荐")
private Integer recommend;
@Schema(description = "排序(数字越小越靠前)")
private Integer sortNumber;
@Schema(description = "状态, 0未受理, 1已受理")
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@Schema(description = "用户ID")
private Integer userId;
@Schema(description = "用户昵称")
@TableField(exist = false)
private String nickname;
@Schema(description = "用户手机号")
@TableField(exist = false)
private String phone;
@Schema(description = "用户头像")
@TableField(exist = false)
private String avatar;
@Schema(description = "真实姓名")
@TableField(exist = false)
private String realName;
@Schema(description = "租户id")
private Integer tenantId;
@Schema(description = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@Schema(description = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
// 第1步案件受理字段
@Schema(description = "第1步是否已提交")
private Integer followStep1Submitted;
@Schema(description = "第1步提交时间")
private String followStep1SubmittedAt;
@Schema(description = "第1步是否需要审核")
private Integer followStep1NeedApproval;
@Schema(description = "第1步是否审核通过")
private Integer followStep1Approved;
@Schema(description = "第1步审核时间")
private String followStep1ApprovedAt;
@Schema(description = "第1步审核人ID")
private Long followStep1ApprovedBy;
// 第2步材料准备字段
@Schema(description = "第2步是否已提交")
private Integer followStep2Submitted;
@Schema(description = "第2步提交时间")
private String followStep2SubmittedAt;
@Schema(description = "第2步是否需要审核")
private Integer followStep2NeedApproval;
@Schema(description = "第2步是否审核通过")
private Integer followStep2Approved;
@Schema(description = "第2步审核时间")
private String followStep2ApprovedAt;
@Schema(description = "第2步审核人ID")
private Long followStep2ApprovedBy;
// 第3步案件办理字段
@Schema(description = "第3步是否已提交")
private Integer followStep3Submitted;
@Schema(description = "第3步提交时间")
private String followStep3SubmittedAt;
@Schema(description = "第3步是否需要审核")
private Integer followStep3NeedApproval;
@Schema(description = "第3步是否审核通过")
private Integer followStep3Approved;
@Schema(description = "第3步审核时间")
private String followStep3ApprovedAt;
@Schema(description = "第3步审核人ID")
private Long followStep3ApprovedBy;
// 第4步送达签收字段
@Schema(description = "第4步是否已提交")
private Integer followStep4Submitted;
@Schema(description = "第4步提交时间")
private String followStep4SubmittedAt;
@Schema(description = "第4步是否需要审核")
private Integer followStep4NeedApproval;
@Schema(description = "第4步是否审核通过")
private Integer followStep4Approved;
@Schema(description = "第4步审核时间")
private String followStep4ApprovedAt;
@Schema(description = "第4步审核人ID")
private Long followStep4ApprovedBy;
// 第5步合同签订字段
@Schema(description = "第5步是否已提交")
private Integer followStep5Submitted;
@Schema(description = "第5步提交时间")
private String followStep5SubmittedAt;
@Schema(description = "第5步合同信息JSON数组")
private String followStep5Contracts;
@Schema(description = "第5步是否需要审核")
private Integer followStep5NeedApproval;
@Schema(description = "第5步是否审核通过")
private Integer followStep5Approved;
@Schema(description = "第5步审核时间")
private String followStep5ApprovedAt;
@Schema(description = "第5步审核人ID")
private Long followStep5ApprovedBy;
// 第6步订单回款字段
@Schema(description = "第6步是否已提交")
private Integer followStep6Submitted;
@Schema(description = "第6步提交时间")
private String followStep6SubmittedAt;
@Schema(description = "第6步财务录入的回款记录JSON数组")
private String followStep6PaymentRecords;
@Schema(description = "第6步预计回款JSON数组")
private String followStep6ExpectedPayments;
@Schema(description = "第6步是否需要审核")
private Integer followStep6NeedApproval;
@Schema(description = "第6步是否审核通过")
private Integer followStep6Approved;
@Schema(description = "第6步审核时间")
private String followStep6ApprovedAt;
@Schema(description = "第6步审核人ID")
private Long followStep6ApprovedBy;
// 第7步电话回访字段
@Schema(description = "第7步是否已提交")
private Integer followStep7Submitted;
@Schema(description = "第7步提交时间")
private String followStep7SubmittedAt;
@Schema(description = "第7步回访记录JSON数组")
private String followStep7VisitRecords;
@Schema(description = "第7步是否需要审核")
private Integer followStep7NeedApproval;
@Schema(description = "第7步是否审核通过")
private Integer followStep7Approved;
@Schema(description = "第7步审核时间")
private String followStep7ApprovedAt;
@Schema(description = "第7步审核人ID")
private Long followStep7ApprovedBy;
// 流程结束字段
@Schema(description = "流程是否已结束")
private Integer followProcessEnded;
@Schema(description = "流程结束时间")
private String followProcessEndTime;
@Schema(description = "流程结束原因")
private String followProcessEndReason;
}

View File

@@ -79,6 +79,9 @@ public class CreditNearbyCompany implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "主体企业")
@TableField(exist = false)
private String companyName;

View File

@@ -50,6 +50,9 @@ public class CreditRiskRelation implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "企业名称")
private String companyName;

View File

@@ -51,6 +51,9 @@ public class CreditSupplier implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "企业名称")
private String companyName;

View File

@@ -64,6 +64,9 @@ public class CreditSuspectedRelationship implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "主体企业")
@TableField(exist = false)
private String companyName;

View File

@@ -81,6 +81,9 @@ public class CreditUser implements Serializable {
@Schema(description = "企业ID")
private Integer companyId;
@Schema(description = "企业别名")
private String companyAlias;
@Schema(description = "企业名称")
private String companyName;

View File

@@ -0,0 +1,47 @@
package com.gxwebsoft.credit.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.credit.entity.CreditMpCustomer;
import com.gxwebsoft.credit.param.CreditMpCustomerParam;
import com.gxwebsoft.credit.param.FollowStepQueryDTO;
import com.gxwebsoft.credit.vo.PendingApprovalStepVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 小程序端客户Mapper
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
public interface CreditMpCustomerMapper extends BaseMapper<CreditMpCustomer> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<CreditMpCustomer>
*/
List<CreditMpCustomer> selectPageRel(@Param("page") IPage<CreditMpCustomer> page,
@Param("param") CreditMpCustomerParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<CreditMpCustomer> selectListRel(@Param("param") CreditMpCustomerParam param);
/**
* 获取待审核的跟进步骤列表
*
* @param query 查询参数
* @return 待审核步骤列表
*/
List<PendingApprovalStepVO> selectPendingApprovalSteps(@Param("param") FollowStepQueryDTO query);
}

View File

@@ -0,0 +1,219 @@
<?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.gxwebsoft.credit.mapper.CreditMpCustomerMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*, u.nickname AS nickname, u.avatar AS avatar, u.phone AS phone, u.real_name AS realName
FROM credit_mp_customer a
LEFT JOIN gxwebsoft_core.sys_user u ON u.user_id = a.user_id
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.toUser != null">
AND a.to_user LIKE CONCAT('%', #{param.toUser}, '%')
</if>
<if test="param.price != null">
AND a.price LIKE CONCAT('%', #{param.price}, '%')
</if>
<if test="param.years != null">
AND a.years LIKE CONCAT('%', #{param.years}, '%')
</if>
<if test="param.url != null">
AND a.url LIKE CONCAT('%', #{param.url}, '%')
</if>
<if test="param.statusTxt != null">
AND a.status_txt LIKE CONCAT('%', #{param.statusTxt}, '%')
</if>
<if test="param.companyId != null">
AND a.company_id = #{param.companyId}
</if>
<if test="param.province != null">
AND a.province LIKE CONCAT('%', #{param.province}, '%')
</if>
<if test="param.city != null">
AND a.city LIKE CONCAT('%', #{param.city}, '%')
</if>
<if test="param.region != null">
AND a.region LIKE CONCAT('%', #{param.region}, '%')
</if>
<if test="param.files != null">
AND a.files LIKE CONCAT('%', #{param.files}, '%')
</if>
<if test="param.hasData != null">
AND a.has_data = #{param.hasData}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.recommend != null">
AND a.recommend = #{param.recommend}
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.step != null">
AND a.step = #{param.step}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR a.to_user LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.credit.entity.CreditMpCustomer">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.credit.entity.CreditMpCustomer">
<include refid="selectSql"></include>
</select>
<!-- 获取待审核的跟进步骤列表 -->
<select id="selectPendingApprovalSteps" resultType="com.gxwebsoft.credit.vo.PendingApprovalStepVO">
SELECT
c.id as customerId,
c.to_user as customerName,
1 as step,
'案件受理' as stepTitle,
c.follow_step1_submitted_at as submittedAt,
u.real_name as submittedBy,
c.comments as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step1_submitted = 1
AND c.follow_step1_approved = 0
AND c.deleted = 0
UNION ALL
SELECT
c.id as customerId,
c.to_user as customerName,
2 as step,
'材料准备' as stepTitle,
c.follow_step2_submitted_at as submittedAt,
u.real_name as submittedBy,
c.comments as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step2_submitted = 1
AND c.follow_step2_approved = 0
AND c.deleted = 0
UNION ALL
SELECT
c.id as customerId,
c.to_user as customerName,
3 as step,
'案件办理' as stepTitle,
c.follow_step3_submitted_at as submittedAt,
u.real_name as submittedBy,
c.comments as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step3_submitted = 1
AND c.follow_step3_approved = 0
AND c.deleted = 0
UNION ALL
SELECT
c.id as customerId,
c.to_user as customerName,
4 as step,
'送达签收' as stepTitle,
c.follow_step4_submitted_at as submittedAt,
u.real_name as submittedBy,
c.comments as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step4_submitted = 1
AND c.follow_step4_approved = 0
AND c.deleted = 0
UNION ALL
SELECT
c.id as customerId,
c.to_user as customerName,
5 as step,
'合同签订' as stepTitle,
c.follow_step5_submitted_at as submittedAt,
u.real_name as submittedBy,
c.follow_step5_contracts as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step5_submitted = 1
AND c.follow_step5_approved = 0
AND c.deleted = 0
UNION ALL
SELECT
c.id as customerId,
c.to_user as customerName,
6 as step,
'订单回款' as stepTitle,
c.follow_step6_submitted_at as submittedAt,
u.real_name as submittedBy,
c.follow_step6_expected_payments as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step6_submitted = 1
AND c.follow_step6_approved = 0
AND c.deleted = 0
UNION ALL
SELECT
c.id as customerId,
c.to_user as customerName,
7 as step,
'电话回访' as stepTitle,
c.follow_step7_submitted_at as submittedAt,
u.real_name as submittedBy,
c.follow_step7_visit_records as content
FROM credit_mp_customer c
LEFT JOIN sys_user u ON c.user_id = u.user_id
WHERE c.follow_step7_submitted = 1
AND c.follow_step7_approved = 0
AND c.deleted = 0
<if test="param.step != null">
HAVING step = #{param.step}
</if>
<if test="param.customerId != null">
HAVING customerId = #{param.customerId}
</if>
<if test="param.userId != null">
HAVING customerId IN (SELECT id FROM credit_mp_customer WHERE user_id = #{param.userId})
</if>
ORDER BY submittedAt DESC
</select>
</mapper>

View File

@@ -0,0 +1,24 @@
package com.gxwebsoft.credit.param;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 批量跟进步骤审核DTO
*
* @author 科技小王子
* @since 2026-03-22
*/
@Data
@Schema(name = "BatchFollowStepApprovalDTO对象", description = "批量跟进步骤审核DTO")
public class BatchFollowStepApprovalDTO {
@Schema(description = "审核列表", required = true)
@NotNull(message = "审核列表不能为空")
@Valid
private List<FollowStepApprovalDTO> approvals;
}

View File

@@ -0,0 +1,91 @@
package com.gxwebsoft.credit.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 小程序端客户查询参数
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(name = "CreditMpCustomerParam对象", description = "小程序端客户查询参数")
public class CreditMpCustomerParam extends BaseParam {
private static final long serialVersionUID = 1L;
@Schema(description = "ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@Schema(description = "拖欠方")
private String toUser;
@Schema(description = "拖欠金额")
private String price;
@Schema(description = "拖欠年数")
private String years;
@Schema(description = "链接")
private String url;
@Schema(description = "状态")
private String statusTxt;
@Schema(description = "企业ID")
@QueryField(type = QueryType.EQ)
private Integer companyId;
@Schema(description = "所在省份")
private String province;
@Schema(description = "所在城市")
private String city;
@Schema(description = "所在辖区")
private String region;
@Schema(description = "文件路径")
private String files;
@Schema(description = "是否有数据")
@QueryField(type = QueryType.EQ)
private Boolean hasData;
@Schema(description = "步骤, 0未受理1已受理2材料提交3合同签订4执行回款5完结")
@QueryField(type = QueryType.EQ)
private Integer step;
@Schema(description = "备注")
private String comments;
@Schema(description = "是否推荐")
@QueryField(type = QueryType.EQ)
private Integer recommend;
@Schema(description = "排序(数字越小越靠前)")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
@Schema(description = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
}

View File

@@ -0,0 +1,24 @@
package com.gxwebsoft.credit.param;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 结束跟进流程DTO
*
* @author 科技小王子
* @since 2026-03-22
*/
@Data
@Schema(name = "EndFollowProcessDTO对象", description = "结束跟进流程DTO")
public class EndFollowProcessDTO {
@Schema(description = "客户ID", required = true)
@NotNull(message = "客户ID不能为空")
private Long customerId;
@Schema(description = "结束原因")
private String reason;
}

View File

@@ -0,0 +1,36 @@
package com.gxwebsoft.credit.param;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Min;
import javax.validation.constraints.Max;
/**
* 跟进步骤审核DTO
*
* @author 科技小王子
* @since 2026-03-22
*/
@Data
@Schema(name = "FollowStepApprovalDTO对象", description = "跟进步骤审核DTO")
public class FollowStepApprovalDTO {
@Schema(description = "客户ID", required = true)
@NotNull(message = "客户ID不能为空")
private Long customerId;
@Schema(description = "步骤号", required = true, example = "5")
@NotNull(message = "步骤号不能为空")
@Min(value = 1, message = "步骤号最小为1")
@Max(value = 7, message = "步骤号最大为7")
private Integer step;
@Schema(description = "是否审核通过", required = true)
@NotNull(message = "审核状态不能为空")
private Boolean approved;
@Schema(description = "审核备注")
private String remark;
}

View File

@@ -0,0 +1,29 @@
package com.gxwebsoft.credit.param;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.Max;
/**
* 跟进步骤查询DTO
*
* @author 科技小王子
* @since 2026-03-22
*/
@Data
@Schema(name = "FollowStepQueryDTO对象", description = "跟进步骤查询DTO")
public class FollowStepQueryDTO {
@Schema(description = "步骤号", example = "5")
@Min(value = 1, message = "步骤号最小为1")
@Max(value = 7, message = "步骤号最大为7")
private Integer step;
@Schema(description = "客户ID")
private Long customerId;
@Schema(description = "用户ID")
private Long userId;
}

View File

@@ -0,0 +1,85 @@
package com.gxwebsoft.credit.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.credit.entity.CreditMpCustomer;
import com.gxwebsoft.credit.param.CreditMpCustomerParam;
import com.gxwebsoft.credit.param.BatchFollowStepApprovalDTO;
import com.gxwebsoft.credit.param.EndFollowProcessDTO;
import com.gxwebsoft.credit.param.FollowStepApprovalDTO;
import com.gxwebsoft.credit.param.FollowStepQueryDTO;
import com.gxwebsoft.credit.vo.FollowStatisticsDTO;
import com.gxwebsoft.credit.vo.PendingApprovalStepVO;
import java.util.List;
/**
* 小程序端客户Service
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
public interface CreditMpCustomerService extends IService<CreditMpCustomer> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<CreditMpCustomer>
*/
PageResult<CreditMpCustomer> pageRel(CreditMpCustomerParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<CreditMpCustomer>
*/
List<CreditMpCustomer> listRel(CreditMpCustomerParam param);
/**
* 根据id查询
*
* @param id ID
* @return CreditMpCustomer
*/
CreditMpCustomer getByIdRel(Integer id);
/**
* 审核跟进步骤
*
* @param dto 审核参数
*/
void approveFollowStep(FollowStepApprovalDTO dto);
/**
* 批量审核跟进步骤
*
* @param dto 批量审核参数
*/
void batchApproveFollowSteps(BatchFollowStepApprovalDTO dto);
/**
* 获取待审核的跟进步骤列表
*
* @param query 查询参数
* @return 待审核步骤列表
*/
List<PendingApprovalStepVO> getPendingApprovalSteps(FollowStepQueryDTO query);
/**
* 获取客户跟进统计
*
* @param customerId 客户ID
* @return 跟进统计信息
*/
FollowStatisticsDTO getFollowStatistics(Long customerId);
/**
* 结束客户跟进流程
*
* @param dto 结束流程参数
*/
void endFollowProcess(EndFollowProcessDTO dto);
}

View File

@@ -0,0 +1,259 @@
package com.gxwebsoft.credit.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.exception.BusinessException;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.credit.mapper.CreditMpCustomerMapper;
import com.gxwebsoft.credit.service.CreditMpCustomerService;
import com.gxwebsoft.credit.entity.CreditMpCustomer;
import com.gxwebsoft.credit.param.CreditMpCustomerParam;
import com.gxwebsoft.credit.param.BatchFollowStepApprovalDTO;
import com.gxwebsoft.credit.param.EndFollowProcessDTO;
import com.gxwebsoft.credit.param.FollowStepApprovalDTO;
import com.gxwebsoft.credit.param.FollowStepQueryDTO;
import com.gxwebsoft.credit.vo.FollowStatisticsDTO;
import com.gxwebsoft.credit.vo.FollowStepDetailDTO;
import com.gxwebsoft.credit.vo.PendingApprovalStepVO;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
/**
* 小程序端客户Service实现
*
* @author 科技小王子
* @since 2026-03-16 20:59:17
*/
@Service
public class CreditMpCustomerServiceImpl extends ServiceImpl<CreditMpCustomerMapper, CreditMpCustomer> implements CreditMpCustomerService {
private final BaseController baseController = new BaseController();
@Override
public PageResult<CreditMpCustomer> pageRel(CreditMpCustomerParam param) {
PageParam<CreditMpCustomer, CreditMpCustomerParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<CreditMpCustomer> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<CreditMpCustomer> listRel(CreditMpCustomerParam param) {
List<CreditMpCustomer> list = baseMapper.selectListRel(param);
// 排序
PageParam<CreditMpCustomer, CreditMpCustomerParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public CreditMpCustomer getByIdRel(Integer id) {
CreditMpCustomerParam param = new CreditMpCustomerParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
@Transactional
public void approveFollowStep(FollowStepApprovalDTO dto) {
CreditMpCustomer customer = getById(dto.getCustomerId());
if (customer == null) {
throw new BusinessException("客户不存在");
}
// 验证步骤是否已提交
if (!isStepSubmitted(customer, dto.getStep())) {
throw new BusinessException("该步骤尚未提交,无法审核");
}
// 更新审核状态
updateStepApproval(customer, dto);
// 如果审核通过,更新客户步骤状态
if (dto.getApproved()) {
updateCustomerStep(customer, dto.getStep());
}
}
@Override
@Transactional
public void batchApproveFollowSteps(BatchFollowStepApprovalDTO dto) {
for (FollowStepApprovalDTO approval : dto.getApprovals()) {
approveFollowStep(approval);
}
}
@Override
public List<PendingApprovalStepVO> getPendingApprovalSteps(FollowStepQueryDTO query) {
return baseMapper.selectPendingApprovalSteps(query);
}
@Override
public FollowStatisticsDTO getFollowStatistics(Long customerId) {
CreditMpCustomer customer = getById(customerId);
if (customer == null) {
throw new BusinessException("客户不存在");
}
FollowStatisticsDTO statistics = new FollowStatisticsDTO();
statistics.setTotalSteps(7);
List<FollowStepDetailDTO> stepDetails = new ArrayList<>();
int completedSteps = 0;
int currentStep = 1;
for (int i = 1; i <= 7; i++) {
FollowStepDetailDTO detail = getStepDetail(customer, i);
stepDetails.add(detail);
if ("approved".equals(detail.getStatus())) {
completedSteps++;
currentStep = i + 1;
} else if ("submitted".equals(detail.getStatus()) && currentStep == 1) {
currentStep = i;
}
}
statistics.setCompletedSteps(completedSteps);
statistics.setCurrentStep(Math.min(currentStep, 7));
statistics.setProgress((double) completedSteps / 7 * 100);
statistics.setStepDetails(stepDetails);
return statistics;
}
@Override
@Transactional
public void endFollowProcess(EndFollowProcessDTO dto) {
CreditMpCustomer customer = getById(dto.getCustomerId());
if (customer == null) {
throw new BusinessException("客户不存在");
}
customer.setFollowProcessEnded(1);
customer.setFollowProcessEndTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
customer.setFollowProcessEndReason(dto.getReason());
updateById(customer);
}
// 私有辅助方法
private boolean isStepSubmitted(CreditMpCustomer customer, Integer step) {
switch (step) {
case 1: return customer.getFollowStep1Submitted() != null && customer.getFollowStep1Submitted() == 1;
case 2: return customer.getFollowStep2Submitted() != null && customer.getFollowStep2Submitted() == 1;
case 3: return customer.getFollowStep3Submitted() != null && customer.getFollowStep3Submitted() == 1;
case 4: return customer.getFollowStep4Submitted() != null && customer.getFollowStep4Submitted() == 1;
case 5: return customer.getFollowStep5Submitted() != null && customer.getFollowStep5Submitted() == 1;
case 6: return customer.getFollowStep6Submitted() != null && customer.getFollowStep6Submitted() == 1;
case 7: return customer.getFollowStep7Submitted() != null && customer.getFollowStep7Submitted() == 1;
default: return false;
}
}
private void updateStepApproval(CreditMpCustomer customer, FollowStepApprovalDTO dto) {
String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
Integer currentUserId = baseController.getLoginUserId();
switch (dto.getStep()) {
case 5:
customer.setFollowStep5Approved(dto.getApproved() ? 1 : 0);
customer.setFollowStep5ApprovedAt(currentTime);
customer.setFollowStep5ApprovedBy(currentUserId != null ? currentUserId.longValue() : null);
break;
case 6:
customer.setFollowStep6Approved(dto.getApproved() ? 1 : 0);
customer.setFollowStep6ApprovedAt(currentTime);
customer.setFollowStep6ApprovedBy(currentUserId != null ? currentUserId.longValue() : null);
break;
case 7:
customer.setFollowStep7Approved(dto.getApproved() ? 1 : 0);
customer.setFollowStep7ApprovedAt(currentTime);
customer.setFollowStep7ApprovedBy(currentUserId != null ? currentUserId.longValue() : null);
break;
}
updateById(customer);
}
private void updateCustomerStep(CreditMpCustomer customer, Integer step) {
// 更新客户的总体步骤状态
if (step >= customer.getStep()) {
customer.setStep(step + 1);
updateById(customer);
}
}
private FollowStepDetailDTO getStepDetail(CreditMpCustomer customer, Integer step) {
FollowStepDetailDTO detail = new FollowStepDetailDTO();
detail.setStep(step);
// 设置步骤标题
String[] stepTitles = {"", "案件受理", "材料准备", "案件办理", "送达签收", "合同签订", "订单回款", "电话回访"};
detail.setTitle(stepTitles[step]);
// 获取步骤状态
boolean submitted = isStepSubmitted(customer, step);
boolean approved = isStepApproved(customer, step);
if (approved) {
detail.setStatus("approved");
detail.setApprovedAt(getStepApprovedAt(customer, step));
} else if (submitted) {
detail.setStatus("submitted");
detail.setSubmittedAt(getStepSubmittedAt(customer, step));
} else {
detail.setStatus("pending");
}
return detail;
}
private boolean isStepApproved(CreditMpCustomer customer, Integer step) {
switch (step) {
case 1: return customer.getFollowStep1Approved() != null && customer.getFollowStep1Approved() == 1;
case 2: return customer.getFollowStep2Approved() != null && customer.getFollowStep2Approved() == 1;
case 3: return customer.getFollowStep3Approved() != null && customer.getFollowStep3Approved() == 1;
case 4: return customer.getFollowStep4Approved() != null && customer.getFollowStep4Approved() == 1;
case 5: return customer.getFollowStep5Approved() != null && customer.getFollowStep5Approved() == 1;
case 6: return customer.getFollowStep6Approved() != null && customer.getFollowStep6Approved() == 1;
case 7: return customer.getFollowStep7Approved() != null && customer.getFollowStep7Approved() == 1;
default: return false;
}
}
private LocalDateTime getStepSubmittedAt(CreditMpCustomer customer, Integer step) {
String submittedAt = null;
switch (step) {
case 1: submittedAt = customer.getFollowStep1SubmittedAt(); break;
case 2: submittedAt = customer.getFollowStep2SubmittedAt(); break;
case 3: submittedAt = customer.getFollowStep3SubmittedAt(); break;
case 4: submittedAt = customer.getFollowStep4SubmittedAt(); break;
case 5: submittedAt = customer.getFollowStep5SubmittedAt(); break;
case 6: submittedAt = customer.getFollowStep6SubmittedAt(); break;
case 7: submittedAt = customer.getFollowStep7SubmittedAt(); break;
}
return submittedAt != null ? LocalDateTime.parse(submittedAt, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null;
}
private LocalDateTime getStepApprovedAt(CreditMpCustomer customer, Integer step) {
String approvedAt = null;
switch (step) {
case 1: approvedAt = customer.getFollowStep1ApprovedAt(); break;
case 2: approvedAt = customer.getFollowStep2ApprovedAt(); break;
case 3: approvedAt = customer.getFollowStep3ApprovedAt(); break;
case 4: approvedAt = customer.getFollowStep4ApprovedAt(); break;
case 5: approvedAt = customer.getFollowStep5ApprovedAt(); break;
case 6: approvedAt = customer.getFollowStep6ApprovedAt(); break;
case 7: approvedAt = customer.getFollowStep7ApprovedAt(); break;
}
return approvedAt != null ? LocalDateTime.parse(approvedAt, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null;
}
}

View File

@@ -0,0 +1,32 @@
package com.gxwebsoft.credit.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* 客户跟进统计DTO
*
* @author 科技小王子
* @since 2026-03-22
*/
@Data
@Schema(name = "FollowStatisticsDTO对象", description = "客户跟进统计DTO")
public class FollowStatisticsDTO {
@Schema(description = "总步骤数")
private Integer totalSteps;
@Schema(description = "已完成步骤数")
private Integer completedSteps;
@Schema(description = "当前步骤")
private Integer currentStep;
@Schema(description = "进度百分比")
private Double progress;
@Schema(description = "步骤详情列表")
private List<FollowStepDetailDTO> stepDetails;
}

View File

@@ -0,0 +1,32 @@
package com.gxwebsoft.credit.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 跟进步骤详情DTO
*
* @author 科技小王子
* @since 2026-03-22
*/
@Data
@Schema(name = "FollowStepDetailDTO对象", description = "跟进步骤详情DTO")
public class FollowStepDetailDTO {
@Schema(description = "步骤号")
private Integer step;
@Schema(description = "步骤标题")
private String title;
@Schema(description = "状态: pending, submitted, approved, rejected")
private String status;
@Schema(description = "提交时间")
private LocalDateTime submittedAt;
@Schema(description = "审核时间")
private LocalDateTime approvedAt;
}

View File

@@ -0,0 +1,38 @@
package com.gxwebsoft.credit.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 待审核跟进步骤VO
*
* @author 科技小王子
* @since 2026-03-22
*/
@Data
@Schema(name = "PendingApprovalStepVO对象", description = "待审核跟进步骤VO")
public class PendingApprovalStepVO {
@Schema(description = "客户ID")
private Long customerId;
@Schema(description = "客户名称")
private String customerName;
@Schema(description = "步骤号")
private Integer step;
@Schema(description = "步骤标题")
private String stepTitle;
@Schema(description = "提交时间")
private LocalDateTime submittedAt;
@Schema(description = "提交人")
private String submittedBy;
@Schema(description = "内容")
private String content;
}

View File

@@ -52,6 +52,34 @@ public class GltTicketOrderController extends BaseController {
return success(gltTicketOrderService.pageRel(param));
}
@PreAuthorize("isAuthenticated()")
@Operation(summary = "配送员端:分页查询可接单的送水订单")
@GetMapping("/rider/available")
public ApiResult<PageResult<GltTicketOrder>> riderAvailablePage(GltTicketOrderParam param) {
User loginUser = getLoginUser();
if (loginUser == null) {
return fail("请先登录", null);
}
Integer tenantId = getTenantId();
param.setTenantId(tenantId);
// 仅允许配送员访问
requireActiveRider(loginUser.getUserId(), tenantId);
// 查询未分配的待配送订单riderId 为空或0
// 设置为0表示查询未分配的订单XML中会处理为 IS NULL OR = 0
param.setRiderId(0);
if (param.getDeliveryStatus() == null) {
param.setDeliveryStatus(GltTicketOrderService.DELIVERY_STATUS_WAITING);
}
// 配送员端默认按期望配送时间优先
if (StrUtil.isBlank(param.getSort())) {
param.setSort("sendTime asc, createTime desc");
}
// 使用现有的关联查询方法,通过参数控制
return success(gltTicketOrderService.pageRel(param));
}
@PreAuthorize("isAuthenticated()")
@Operation(summary = "配送员端:分页查询我的送水订单")
@GetMapping("/rider/page")
@@ -65,8 +93,12 @@ public class GltTicketOrderController extends BaseController {
// 仅允许配送员访问
requireActiveRider(loginUser.getUserId(), tenantId);
// 关键修复:配送员只能看到分配给自己的订单
param.setRiderId(loginUser.getUserId());
// 默认查询待配送和配送中的订单
if (param.getDeliveryStatus() == null) {
// 可以通过参数传递多个状态,这里简化为只查待配送
param.setDeliveryStatus(GltTicketOrderService.DELIVERY_STATUS_WAITING);
}
// 配送员端默认按期望配送时间优先
@@ -241,8 +273,33 @@ public class GltTicketOrderController extends BaseController {
@Operation(summary = "修改送水订单")
@PutMapping()
public ApiResult<?> update(@RequestBody GltTicketOrder gltTicketOrder) {
if (gltTicketOrder == null || gltTicketOrder.getId() == null) {
return fail("订单ID不能为空");
}
Integer tenantId = getTenantId();
// 根据 addressId 同步更新订单地址快照
if (gltTicketOrder.getAddressId() != null) {
ShopUserAddress userAddress = shopUserAddressService.getByIdRel(gltTicketOrder.getAddressId());
if (userAddress == null) {
return fail("收货地址不存在");
}
if (tenantId != null && userAddress.getTenantId() != null && !tenantId.equals(userAddress.getTenantId())) {
return fail("收货地址不存在或无权限");
}
GltTicketOrder oldOrder = gltTicketOrderService.getById(gltTicketOrder.getId());
if (oldOrder == null) {
return fail("订单不存在");
}
Integer targetUserId = gltTicketOrder.getUserId() != null ? gltTicketOrder.getUserId() : oldOrder.getUserId();
if (targetUserId != null && userAddress.getUserId() != null && !targetUserId.equals(userAddress.getUserId())) {
return fail("收货地址不存在或无权限");
}
gltTicketOrder.setAddressId(userAddress.getId());
gltTicketOrder.setAddress(buildAddressSnapshot(userAddress));
}
if (gltTicketOrderService.updateById(gltTicketOrder)) {
Integer tenantId = getTenantId();
// 后台指派配送员(直接改 riderId同步商城订单为“已发货”(deliveryStatus=20)
if (gltTicketOrder != null
&& gltTicketOrder.getId() != null

View File

@@ -58,6 +58,9 @@ public class GltTicketTemplate implements Serializable {
@Schema(description = "首期释放时机0=支付成功当刻1=下个月同日")
private Integer firstReleaseMode;
@Schema(description = "步长")
private Integer step;
@Schema(description = "用户ID")
private Integer userId;

View File

@@ -32,7 +32,12 @@
AND a.store_id = #{param.storeId}
</if>
<if test="param.riderId != null">
AND a.rider_id = #{param.riderId}
<if test="param.riderId == 0">
AND (a.rider_id IS NULL OR a.rider_id = 0)
</if>
<if test="param.riderId != 0">
AND a.rider_id = #{param.riderId}
</if>
</if>
<if test="param.deliveryStatus != null">
AND a.delivery_status = #{param.deliveryStatus}

View File

@@ -146,7 +146,9 @@ public class DealerOrderSettlement10584Task {
.eq(ShopOrder::getTenantId, TENANT_ID)
.eq(ShopOrder::getDeleted, 0)
.eq(ShopOrder::getPayStatus, true)
.eq(ShopOrder::getIsSettled, 0);
.eq(ShopOrder::getIsSettled, 0)
// 退款/取消订单不结算,避免“退款后仍发放分红/分润/佣金”
.and(w -> w.notIn(ShopOrder::getOrderStatus, 2, 4, 5, 6, 7).or().isNull(ShopOrder::getOrderStatus));
if (waterFormIds != null && !waterFormIds.isEmpty()) {
qw.and(w -> w.eq(ShopOrder::getDeliveryStatus, 20).or().in(ShopOrder::getFormId, waterFormIds));
@@ -162,7 +164,9 @@ public class DealerOrderSettlement10584Task {
LambdaUpdateWrapper<ShopOrder> uw = new LambdaUpdateWrapper<ShopOrder>()
.eq(ShopOrder::getOrderId, orderId)
.eq(ShopOrder::getTenantId, TENANT_ID)
.eq(ShopOrder::getIsSettled, 0);
.eq(ShopOrder::getIsSettled, 0)
// 二次防御:退款/取消订单不允许被“认领结算”
.and(w -> w.notIn(ShopOrder::getOrderStatus, 2, 4, 5, 6, 7).or().isNull(ShopOrder::getOrderStatus));
if (waterFormIds != null && !waterFormIds.isEmpty()) {
uw.and(w -> w.eq(ShopOrder::getDeliveryStatus, 20).or().in(ShopOrder::getFormId, waterFormIds));

View File

@@ -105,6 +105,8 @@ public class ShopOrderController extends BaseController {
private ShopStoreFenceService shopStoreFenceService;
@Resource
private GltTicketRevokeService gltTicketRevokeService;
@Resource
private ShopDealerCommissionRollbackService shopDealerCommissionRollbackService;
@Operation(summary = "分页查询订单")
@GetMapping("/page")
@@ -559,6 +561,24 @@ public class ShopOrderController extends BaseController {
current.getTenantId(), current.getOrderId(), current.getOrderNo(), e);
}
// 退款成功后回退分红/分润/佣金(从 ShopDealerUser 中扣回;以 ShopDealerCapital 明细为准)
try {
Integer tenantId = ObjectUtil.defaultIfNull(current.getTenantId(), getTenantId());
ShopOrder rollbackOrder = new ShopOrder();
rollbackOrder.setTenantId(tenantId);
rollbackOrder.setOrderNo(current.getOrderNo());
rollbackOrder.setPayPrice(current.getPayPrice());
rollbackOrder.setTotalPrice(current.getTotalPrice());
boolean rollbackOk = shopDealerCommissionRollbackService.rollbackOnOrderRefund(rollbackOrder, refundAmount);
if (!rollbackOk) {
logger.error("退款成功但回退分红/分润/佣金失败 - tenantId={}, orderId={}, orderNo={}",
tenantId, current.getOrderId(), current.getOrderNo());
}
} catch (Exception e) {
logger.error("退款成功但回退分红/分润/佣金异常 - tenantId={}, orderId={}, orderNo={}",
current.getTenantId(), current.getOrderId(), current.getOrderNo(), e);
}
logger.info("订单退款请求成功 - 订单号: {}, 退款单号: {}, 微信退款单号: {}",
current.getOrderNo(), refundNo, refundResponse.getTransactionId());
return success("退款成功");

View File

@@ -37,6 +37,10 @@ public class ShopDealerCapital implements Serializable {
@Schema(description = "订单编号")
private String orderNo;
@Schema(description = "订单状态")
@TableField(exist = false)
private Integer orderStatus;
@Schema(description = "资金流动类型 (10佣金收入 20提现支出 30转账支出 40转账收入 50佣金解冻 60配送奖励)")
private Integer flowType;

View File

@@ -4,11 +4,12 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*, b.order_no, b.month, c.nickname AS nickName, d.nickname AS toNickName
SELECT a.*, b.order_no, b.month, c.nickname AS nickName, d.nickname AS toNickName, e.order_status AS orderStatus
FROM shop_dealer_capital a
LEFT JOIN shop_dealer_order b ON a.order_no = b.order_no
LEFT JOIN gxwebsoft_core.sys_user c ON a.user_id = c.user_id and c.deleted = 0
LEFT JOIN gxwebsoft_core.sys_user d ON a.to_user_id = d.user_id and d.deleted = 0
LEFT JOIN shop_order e ON a.order_no = e.order_no
<where>
<if test="param.id != null">
AND a.id = #{param.id}

View File

@@ -0,0 +1,21 @@
package com.gxwebsoft.shop.service;
import com.gxwebsoft.shop.entity.ShopOrder;
import java.math.BigDecimal;
/**
* 分销/分红/分润:订单退款回退
*/
public interface ShopDealerCommissionRollbackService {
/**
* 订单退款成功后,按订单号回退已入账(冻结/可提现)的分销佣金/分红/分润等金额。
*
* @param order 订单(必须包含 tenantId、orderNo
* @param refundAmount 退款金额(允许为空;为空则按全额退款处理)
* @return true=执行成功或无可回退数据false=执行失败
*/
boolean rollbackOnOrderRefund(ShopOrder order, BigDecimal refundAmount);
}

View File

@@ -0,0 +1,189 @@
package com.gxwebsoft.shop.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gxwebsoft.shop.entity.ShopDealerCapital;
import com.gxwebsoft.shop.entity.ShopDealerOrder;
import com.gxwebsoft.shop.entity.ShopDealerUser;
import com.gxwebsoft.shop.entity.ShopOrder;
import com.gxwebsoft.shop.service.ShopDealerCapitalService;
import com.gxwebsoft.shop.service.ShopDealerCommissionRollbackService;
import com.gxwebsoft.shop.service.ShopDealerOrderService;
import com.gxwebsoft.shop.service.ShopDealerUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class ShopDealerCommissionRollbackServiceImpl implements ShopDealerCommissionRollbackService {
private static final int FLOW_TYPE_COMMISSION_INCOME = 10;
private static final int FLOW_TYPE_COMMISSION_UNFREEZE_MARKER = 50;
private static final int FLOW_TYPE_DELIVERY_REWARD = 60;
@Resource
private ShopDealerCapitalService shopDealerCapitalService;
@Resource
private ShopDealerUserService shopDealerUserService;
@Resource
private ShopDealerOrderService shopDealerOrderService;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean rollbackOnOrderRefund(ShopOrder order, BigDecimal refundAmount) {
if (order == null || order.getTenantId() == null || order.getOrderNo() == null || order.getOrderNo().isBlank()) {
return true;
}
Integer tenantId = order.getTenantId();
String orderNo = order.getOrderNo();
BigDecimal orderBaseAmount = ObjectUtil.defaultIfNull(order.getPayPrice(), order.getTotalPrice());
BigDecimal ratio = resolveRefundRatio(orderBaseAmount, refundAmount);
List<ShopDealerCapital> capitals = shopDealerCapitalService.list(
new LambdaQueryWrapper<ShopDealerCapital>()
.eq(ShopDealerCapital::getTenantId, tenantId)
.eq(ShopDealerCapital::getOrderNo, orderNo)
.in(ShopDealerCapital::getFlowType, FLOW_TYPE_COMMISSION_INCOME, FLOW_TYPE_DELIVERY_REWARD)
.isNotNull(ShopDealerCapital::getUserId)
.isNotNull(ShopDealerCapital::getMoney)
.gt(ShopDealerCapital::getMoney, BigDecimal.ZERO)
);
if (capitals == null || capitals.isEmpty()) {
// 仍标记分销订单失效,避免后续统计误判
markDealerOrderInvalid(tenantId, orderNo);
return true;
}
Map<Integer, BigDecimal> freezeDeductByUser = new HashMap<>();
Map<Integer, BigDecimal> moneyDeductByUser = new HashMap<>();
Map<Integer, BigDecimal> totalDeductByUser = new HashMap<>();
for (ShopDealerCapital cap : capitals) {
Integer dealerUserId = cap.getUserId();
BigDecimal amount = cap.getMoney();
if (dealerUserId == null || amount == null || amount.signum() <= 0) {
continue;
}
BigDecimal rollbackAmount = amount.multiply(ratio).setScale(2, RoundingMode.HALF_UP);
if (rollbackAmount.signum() <= 0) {
continue;
}
totalDeductByUser.merge(dealerUserId, rollbackAmount, BigDecimal::add);
Integer flowType = cap.getFlowType();
if (flowType != null && flowType == FLOW_TYPE_DELIVERY_REWARD) {
moneyDeductByUser.merge(dealerUserId, rollbackAmount, BigDecimal::add);
continue;
}
// 佣金收入:若已解冻(有 flowType=50 marker),则从可提现扣回;否则从冻结扣回
boolean unfrozen = hasUnfreezeMarker(tenantId, cap);
if (unfrozen) {
moneyDeductByUser.merge(dealerUserId, rollbackAmount, BigDecimal::add);
} else {
freezeDeductByUser.merge(dealerUserId, rollbackAmount, BigDecimal::add);
}
}
LocalDateTime now = LocalDateTime.now();
for (Map.Entry<Integer, BigDecimal> entry : totalDeductByUser.entrySet()) {
Integer dealerUserId = entry.getKey();
BigDecimal totalDeduct = entry.getValue();
if (dealerUserId == null || totalDeduct == null || totalDeduct.signum() <= 0) {
continue;
}
BigDecimal freezeDeduct = freezeDeductByUser.getOrDefault(dealerUserId, BigDecimal.ZERO);
BigDecimal moneyDeduct = moneyDeductByUser.getOrDefault(dealerUserId, BigDecimal.ZERO);
LambdaUpdateWrapper<ShopDealerUser> uw = new LambdaUpdateWrapper<ShopDealerUser>()
.eq(ShopDealerUser::getTenantId, tenantId)
.eq(ShopDealerUser::getUserId, dealerUserId)
.setSql("total_money = IFNULL(total_money,0) - " + totalDeduct.toPlainString())
.set(ShopDealerUser::getUpdateTime, now);
if (freezeDeduct.signum() > 0) {
uw.setSql("freeze_money = IFNULL(freeze_money,0) - " + freezeDeduct.toPlainString());
}
if (moneyDeduct.signum() > 0) {
uw.setSql("money = IFNULL(money,0) - " + moneyDeduct.toPlainString());
}
boolean updated = shopDealerUserService.update(uw);
if (!updated) {
log.warn("订单退款扣回分销金额失败:未找到分销账户 - tenantId={}, orderNo={}, dealerUserId={}, totalDeduct={}, freezeDeduct={}, moneyDeduct={}",
tenantId, orderNo, dealerUserId, totalDeduct, freezeDeduct, moneyDeduct);
}
}
markDealerOrderInvalid(tenantId, orderNo);
return true;
}
private boolean hasUnfreezeMarker(Integer tenantId, ShopDealerCapital cap) {
if (tenantId == null || cap == null || cap.getId() == null || cap.getUserId() == null || cap.getOrderNo() == null) {
return false;
}
String markerComment = buildUnfreezeMarkerComment(cap.getId());
return shopDealerCapitalService.count(
new LambdaQueryWrapper<ShopDealerCapital>()
.eq(ShopDealerCapital::getTenantId, tenantId)
.eq(ShopDealerCapital::getFlowType, FLOW_TYPE_COMMISSION_UNFREEZE_MARKER)
.eq(ShopDealerCapital::getUserId, cap.getUserId())
.eq(ShopDealerCapital::getOrderNo, cap.getOrderNo())
.eq(ShopDealerCapital::getComments, markerComment)
) > 0;
}
private String buildUnfreezeMarkerComment(Integer capitalId) {
return "佣金解冻(capitalId=" + capitalId + ")";
}
private BigDecimal resolveRefundRatio(BigDecimal orderBaseAmount, BigDecimal refundAmount) {
if (refundAmount == null || refundAmount.signum() <= 0) {
return BigDecimal.ONE;
}
if (orderBaseAmount == null || orderBaseAmount.signum() <= 0) {
return BigDecimal.ONE;
}
if (refundAmount.compareTo(orderBaseAmount) >= 0) {
return BigDecimal.ONE;
}
return refundAmount.divide(orderBaseAmount, 10, RoundingMode.HALF_UP);
}
private void markDealerOrderInvalid(Integer tenantId, String orderNo) {
if (tenantId == null || orderNo == null || orderNo.isBlank()) {
return;
}
try {
shopDealerOrderService.update(
new LambdaUpdateWrapper<ShopDealerOrder>()
.eq(ShopDealerOrder::getTenantId, tenantId)
.eq(ShopDealerOrder::getOrderNo, orderNo)
.set(ShopDealerOrder::getIsInvalid, 1)
.set(ShopDealerOrder::getUpdateTime, LocalDateTime.now())
);
} catch (Exception e) {
log.warn("订单退款标记分销订单失效失败 - tenantId={}, orderNo={}", tenantId, orderNo, e);
}
}
}

View File

@@ -0,0 +1,86 @@
# 服务器配置
server:
port: 9300
# 数据源配置
spring:
datasource:
url: jdbc:mysql://1Panel-mysql-XsWW:3306/gltdb?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: gltdb
password: EeD4FtzyA5ksj7Bk
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
druid:
remove-abandoned: true
# redis
redis:
database: 0
host: 1Panel-redis-GmNr
port: 6379
password: redis_t74P8C
# 日志配置
logging:
file:
name: websoft-modules.log
level:
root: WARN
com.gxwebsoft: ERROR
com.baomidou.mybatisplus: ERROR
socketio:
host: 0.0.0.0 #IP地址
# MQTT配置
mqtt:
enabled: false # 启用MQTT服务
host: tcp://132.232.214.96:1883
username: swdev
password: Sw20250523
client-id-prefix: hjm_car_
topic: /SW_GPS/#
qos: 2
connection-timeout: 10
keep-alive-interval: 20
auto-reconnect: true
# 框架配置
config:
# 文件服务器
file-server: https://file-s209.shoplnk.cn
# 生产环境接口
server-url: https://glt-server.websoft.top/api
# 业务模块接口
api-url: https://glt-api.websoft.top/api
upload-path: /www/wwwroot/file.ws
# 阿里云OSS云存储
endpoint: https://oss-cn-shenzhen.aliyuncs.com
accessKeyId: LTAI4GKGZ9Z2Z8JZ77c3GNZP
accessKeySecret: BiDkpS7UXj72HWwDWaFZxiXjNFBNCM
bucketName: oss-gxwebsoft
bucketDomain: https://oss.wsdns.cn
aliyunDomain: https://oss-gxwebsoft.oss-cn-shenzhen.aliyuncs.com
# 生产环境证书配置
certificate:
load-mode: VOLUME # 生产环境从Docker挂载卷加载
cert-root-path: /www/wwwroot/file.ws
# 支付配置缓存
payment:
cache:
# 支付配置缓存键前缀,生产环境使用 Payment:1* 格式
key-prefix: "Payment:1"
# 缓存过期时间(小时)
expire-hours: 24
# 阿里云翻译配置
aliyun:
translate:
access-key-id: LTAI5tEsyhW4GCKbds1qsopg
access-key-secret: zltFlQrYVAoq2KMFDWgLa3GhkMNeyO
endpoint: mt.cn-hangzhou.aliyuncs.com
wechatpay:
transfer:
scene-id: 1005
scene-report-infos-json: '[{"info_type":"岗位类型","info_content":"配送员"},{"info_type":"报酬说明","info_content":"12月份配送费"}]'

View File

@@ -0,0 +1,381 @@
package com.gxwebsoft.generator;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.gxwebsoft.generator.engine.BeetlTemplateEnginePlus;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* CMS模块-代码生成工具
*
* @author WebSoft
* @since 2021-09-05 00:31:14
*/
public class YsbGenerator {
// 输出位置
private static final String OUTPUT_LOCATION = System.getProperty("user.dir");
//private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径
// JAVA输出目录
private static final String OUTPUT_DIR = "/src/main/java";
// Vue文件输出位置
private static final String OUTPUT_LOCATION_VUE = "/Users/gxwebsoft/VUE/mp-vue";
// UniApp文件输出目录
private static final String OUTPUT_LOCATION_UNIAPP = "/Users/gxwebsoft/VUE/template-10579";
// Vue文件输出目录
private static final String OUTPUT_DIR_VUE = "/src";
// 作者名称
private static final String AUTHOR = "科技小王子";
// 是否在xml中添加二级缓存配置
private static final boolean ENABLE_CACHE = false;
// 数据库连接配置
private static final String DB_URL = "jdbc:mysql://47.119.165.234:13308/ysb?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String DB_USERNAME = "ysb";
private static final String DB_PASSWORD = "5Zf45CE2YneBfXkR";
// 包名
private static final String PACKAGE_NAME = "com.gxwebsoft";
// 模块名
private static final String MODULE_NAME = "credit";
// 需要生成的表
private static final String[] TABLE_NAMES = new String[]{
"credit_mp_customer",
};
// 需要去除的表前缀
private static final String[] TABLE_PREFIX = new String[]{
"tb_"
};
// 不需要作为查询参数的字段
private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{
"tenant_id",
"create_time",
"update_time"
};
// 查询参数使用String的类型
private static final String[] PARAM_TO_STRING_TYPE = new String[]{
"Date",
"LocalDate",
"LocalTime",
"LocalDateTime"
};
// 查询参数使用EQ的类型
private static final String[] PARAM_EQ_TYPE = new String[]{
"Integer",
"Boolean",
"BigDecimal"
};
// 是否添加权限注解
private static final boolean AUTH_ANNOTATION = true;
// 是否添加日志注解
private static final boolean LOG_ANNOTATION = true;
// controller的mapping前缀
private static final String CONTROLLER_MAPPING_PREFIX = "/api";
// 模板所在位置
private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates";
public static void main(String[] args) {
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
gc.setOutputDir(OUTPUT_LOCATION + OUTPUT_DIR);
gc.setAuthor(AUTHOR);
gc.setOpen(false);
gc.setFileOverride(true);
gc.setEnableCache(ENABLE_CACHE);
gc.setSwagger2(true);
gc.setIdType(IdType.AUTO);
gc.setServiceName("%sService");
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setUrl(DB_URL);
// dsc.setSchemaName("public");
dsc.setDriverName(DB_DRIVER);
dsc.setUsername(DB_USERNAME);
dsc.setPassword(DB_PASSWORD);
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setModuleName(MODULE_NAME);
pc.setParent(PACKAGE_NAME);
mpg.setPackageInfo(pc);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
strategy.setInclude(TABLE_NAMES);
strategy.setTablePrefix(TABLE_PREFIX);
strategy.setSuperControllerClass(PACKAGE_NAME + ".common.core.web.BaseController");
strategy.setEntityLombokModel(true);
strategy.setRestControllerStyle(true);
strategy.setControllerMappingHyphenStyle(true);
strategy.setLogicDeleteFieldName("deleted");
mpg.setStrategy(strategy);
// 模板配置
TemplateConfig templateConfig = new TemplateConfig();
templateConfig.setController(TEMPLATES_DIR + "/controller.java");
templateConfig.setEntity(TEMPLATES_DIR + "/entity.java");
templateConfig.setMapper(TEMPLATES_DIR + "/mapper.java");
templateConfig.setXml(TEMPLATES_DIR + "/mapper.xml");
templateConfig.setService(TEMPLATES_DIR + "/service.java");
templateConfig.setServiceImpl(TEMPLATES_DIR + "/serviceImpl.java");
mpg.setTemplate(templateConfig);
mpg.setTemplateEngine(new BeetlTemplateEnginePlus());
// 自定义模板配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
Map<String, Object> map = new HashMap<>();
map.put("packageName", PACKAGE_NAME);
map.put("paramExcludeFields", PARAM_EXCLUDE_FIELDS);
map.put("paramToStringType", PARAM_TO_STRING_TYPE);
map.put("paramEqType", PARAM_EQ_TYPE);
map.put("authAnnotation", AUTH_ANNOTATION);
map.put("logAnnotation", LOG_ANNOTATION);
map.put("controllerMappingPrefix", CONTROLLER_MAPPING_PREFIX);
// 添加项目类型标识,用于模板中的条件判断
map.put("isUniApp", false); // Vue 项目
map.put("isVueAdmin", true); // 后台管理项目
this.setMap(map);
}
};
String templatePath = TEMPLATES_DIR + "/param.java.btl";
List<FileOutConfig> focList = new ArrayList<>();
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION + OUTPUT_DIR + "/"
+ PACKAGE_NAME.replace(".", "/")
+ "/" + pc.getModuleName() + "/param/"
+ tableInfo.getEntityName() + "Param" + StringPool.DOT_JAVA;
}
});
/**
* 以下是生成VUE项目代码
* 生成文件的路径 /api/shop/goods/index.ts
*/
templatePath = TEMPLATES_DIR + "/index.ts.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/api/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.ts";
}
});
// UniApp 使用专门的模板
String uniappTemplatePath = TEMPLATES_DIR + "/index.ts.uniapp.btl";
focList.add(new FileOutConfig(uniappTemplatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/api/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.ts";
}
});
// 生成TS文件 (/api/shop/goods/model/index.ts)
templatePath = TEMPLATES_DIR + "/model.ts.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/api/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/model/" + "index.ts";
}
});
// UniApp 使用专门的 model 模板
String uniappModelTemplatePath = TEMPLATES_DIR + "/model.ts.uniapp.btl";
focList.add(new FileOutConfig(uniappModelTemplatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/api/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/model/" + "index.ts";
}
});
// 生成Vue文件(/views/shop/goods/index.vue)
templatePath = TEMPLATES_DIR + "/index.vue.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/views/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.vue";
}
});
// 生成components文件(/views/shop/goods/components/edit.vue)
templatePath = TEMPLATES_DIR + "/components.edit.vue.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/views/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/components/" + tableInfo.getEntityPath() + "Edit.vue";
}
});
// 生成components文件(/views/shop/goods/components/search.vue)
templatePath = TEMPLATES_DIR + "/components.search.vue.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE
+ "/views/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/components/" + "search.vue";
}
});
// ========== 移动端页面文件生成 ==========
// 生成移动端列表页面配置文件 (/src/shop/goods/index.config.ts)
templatePath = TEMPLATES_DIR + "/index.config.ts.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.config.ts";
}
});
// 生成移动端列表页面组件文件 (/src/shop/goods/index.tsx)
templatePath = TEMPLATES_DIR + "/index.tsx.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "index.tsx";
}
});
// 生成移动端新增/编辑页面配置文件 (/src/shop/goods/add.config.ts)
templatePath = TEMPLATES_DIR + "/add.config.ts.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "add.config.ts";
}
});
// 生成移动端新增/编辑页面组件文件 (/src/shop/goods/add.tsx)
templatePath = TEMPLATES_DIR + "/add.tsx.btl";
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE
+ "/" + pc.getModuleName() + "/"
+ tableInfo.getEntityPath() + "/" + "add.tsx";
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
mpg.execute();
// 自动更新 app.config.ts
updateAppConfig(TABLE_NAMES, MODULE_NAME);
}
/**
* 自动更新 app.config.ts 文件,添加新生成的页面路径
*/
private static void updateAppConfig(String[] tableNames, String moduleName) {
String appConfigPath = OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE + "/app.config.ts";
try {
// 读取原文件内容
String content = new String(Files.readAllBytes(Paths.get(appConfigPath)));
// 为每个表生成页面路径
StringBuilder newPages = new StringBuilder();
for (String tableName : tableNames) {
String entityPath = tableName.replaceAll("_", "");
// 转换为驼峰命名
String[] parts = tableName.split("_");
StringBuilder camelCase = new StringBuilder(parts[0]);
for (int i = 1; i < parts.length; i++) {
camelCase.append(parts[i].substring(0, 1).toUpperCase()).append(parts[i].substring(1));
}
entityPath = camelCase.toString();
newPages.append(" '").append(entityPath).append("/index',\n");
newPages.append(" '").append(entityPath).append("/add',\n");
}
// 查找对应模块的子包配置
String modulePattern = "\"root\":\\s*\"" + moduleName + "\",\\s*\"pages\":\\s*\\[([^\\]]*)]";
Pattern pattern = Pattern.compile(modulePattern, Pattern.DOTALL);
Matcher matcher = pattern.matcher(content);
if (matcher.find()) {
String existingPages = matcher.group(1);
// 检查页面是否已存在,避免重复添加
boolean needUpdate = false;
String[] newPageArray = newPages.toString().split("\n");
for (String newPage : newPageArray) {
if (!newPage.trim().isEmpty() && !existingPages.contains(newPage.trim().replace(" ", "").replace(",", ""))) {
needUpdate = true;
break;
}
}
if (needUpdate) {
// 备份原文件
String backupPath = appConfigPath + ".backup." + System.currentTimeMillis();
Files.copy(Paths.get(appConfigPath), Paths.get(backupPath));
System.out.println("已备份原文件到: " + backupPath);
// 在现有页面列表末尾添加新页面
String updatedPages = existingPages.trim();
if (!updatedPages.endsWith(",")) {
updatedPages += ",";
}
updatedPages += "\n" + newPages.toString().trim();
// 替换内容
String updatedContent = content.replace(matcher.group(1), updatedPages);
// 写入更新后的内容
Files.write(Paths.get(appConfigPath), updatedContent.getBytes());
System.out.println("✅ 已自动更新 app.config.ts添加了以下页面路径:");
System.out.println(newPages.toString());
} else {
System.out.println(" app.config.ts 中已包含所有页面路径,无需更新");
}
} else {
System.out.println("⚠️ 未找到 " + moduleName + " 模块的子包配置,请手动添加页面路径");
}
} catch (Exception e) {
System.err.println("❌ 更新 app.config.ts 失败: " + e.getMessage());
e.printStackTrace();
}
}
}