feat(审核): 新增待审计数统计接口,支撑个人中心药审核徽标
背景:个人中心「药审核」入口需要展示待审核任务数(红色徽标)。 该口径涉及 4 张表、5 个审核来源,且状态码语义各不相同,不能一概而论: - yxe_user_task.status 待审核是 1(0 待执行 / 1 已完成待审核 / 2 已完成 / 3 已拒绝) - yxe_self_report / yxe_visit_report / yxe_share 待审核都是 0 - 同一张 yxe_user_task 还要按分类拆开:药动销 = cate_id IN (1,3), 跑店/巡店 = cate_id = 4(与审核页 cateIdList=1,3 / cateId=4 对齐) 故新增 /api/yxe/yxe-audit/pending-count,一次返回 5 类明细 + total, 口径与审核页各类型「待审核」列表的总数完全一致,保证入口徽标与 点进去的列表条数对得上。 权限:非审核员(can_auth != 1)与未登录一律返回 0,不下发全站待审量。 验证(本地库 yaoxiaoer,审核员账号实测): 分类 接口 审核页列表 药动销 110 110 跑店/巡店 2 2 驻店填报 787 787 跑店填报 0 0 药分享 36 36 合计 935 - 匿名请求与 can_auth=0 账号请求均返回 total=0,确认拦截生效。
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
package com.gxwebsoft.yxe.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.yxe.entity.YxeSelfReport;
|
||||
import com.gxwebsoft.yxe.entity.YxeShare;
|
||||
import com.gxwebsoft.yxe.entity.YxeUserTask;
|
||||
import com.gxwebsoft.yxe.entity.YxeVisitReport;
|
||||
import com.gxwebsoft.yxe.service.YxeSelfReportService;
|
||||
import com.gxwebsoft.yxe.service.YxeShareService;
|
||||
import com.gxwebsoft.yxe.service.YxeUserTaskService;
|
||||
import com.gxwebsoft.yxe.service.YxeVisitReportService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 审核中心控制器
|
||||
*
|
||||
* @author Codex
|
||||
* @since 2026-10-12
|
||||
*/
|
||||
@Api(tags = "审核中心")
|
||||
@RestController
|
||||
@RequestMapping("/api/yxe/yxe-audit")
|
||||
public class YxeAuditController extends BaseController {
|
||||
|
||||
/** 药动销审核覆盖的任务分类:日常驻店、培训/拜访(与审核页 cateIdList=1,3 保持一致) */
|
||||
private static final Integer[] MOVEMENT_CATE_IDS = {1, 3};
|
||||
|
||||
/** 跑店/巡店的任务分类 */
|
||||
private static final Integer STORE_VISIT_CATE_ID = 4;
|
||||
|
||||
/** 用户任务:1 已完成待审核(审核页「待审核」对应的库值) */
|
||||
private static final Integer TASK_STATUS_PENDING_AUDIT = 1;
|
||||
|
||||
/** 填报与药分享:0 待审核 */
|
||||
private static final Integer STATUS_PENDING_AUDIT = 0;
|
||||
|
||||
@Resource
|
||||
private YxeUserTaskService yxeUserTaskService;
|
||||
@Resource
|
||||
private YxeSelfReportService yxeSelfReportService;
|
||||
@Resource
|
||||
private YxeVisitReportService yxeVisitReportService;
|
||||
@Resource
|
||||
private YxeShareService yxeShareService;
|
||||
|
||||
@ApiOperation("待审核数量统计")
|
||||
@GetMapping("/pending-count")
|
||||
public ApiResult<?> pendingCount() {
|
||||
User loginUser = getLoginUser();
|
||||
// 审核入口只对审核员开放,非审核员不下发全站待审量,直接返回 0
|
||||
if (loginUser == null || !Integer.valueOf(1).equals(loginUser.getCanAuth())) {
|
||||
return success(emptyCount());
|
||||
}
|
||||
// 口径与审核页各类型「待审核」列表的总数一致,保证入口徽标与列表条数对得上
|
||||
long movement = yxeUserTaskService.count(new LambdaQueryWrapper<YxeUserTask>()
|
||||
.in(YxeUserTask::getCateId, (Object[]) MOVEMENT_CATE_IDS)
|
||||
.eq(YxeUserTask::getStatus, TASK_STATUS_PENDING_AUDIT));
|
||||
long storeVisit = yxeUserTaskService.count(new LambdaQueryWrapper<YxeUserTask>()
|
||||
.eq(YxeUserTask::getCateId, STORE_VISIT_CATE_ID)
|
||||
.eq(YxeUserTask::getStatus, TASK_STATUS_PENDING_AUDIT));
|
||||
long selfReport = yxeSelfReportService.count(new LambdaQueryWrapper<YxeSelfReport>()
|
||||
.eq(YxeSelfReport::getStatus, STATUS_PENDING_AUDIT));
|
||||
long visitReport = yxeVisitReportService.count(new LambdaQueryWrapper<YxeVisitReport>()
|
||||
.eq(YxeVisitReport::getStatus, STATUS_PENDING_AUDIT));
|
||||
long exchange = yxeShareService.count(new LambdaQueryWrapper<YxeShare>()
|
||||
.eq(YxeShare::getStatus, STATUS_PENDING_AUDIT));
|
||||
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("total", movement + storeVisit + selfReport + visitReport + exchange);
|
||||
data.put("movement", movement);
|
||||
data.put("storeVisit", storeVisit);
|
||||
data.put("selfReport", selfReport);
|
||||
data.put("visitReport", visitReport);
|
||||
data.put("exchange", exchange);
|
||||
return success(data);
|
||||
}
|
||||
|
||||
private Map<String, Object> emptyCount() {
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("total", 0L);
|
||||
data.put("movement", 0L);
|
||||
data.put("storeVisit", 0L);
|
||||
data.put("selfReport", 0L);
|
||||
data.put("visitReport", 0L);
|
||||
data.put("exchange", 0L);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user