From e01acf486d31cec9037323c4c5dc6ffe0381e591 Mon Sep 17 00:00:00 2001 From: weicw1996 Date: Mon, 12 Oct 2026 16:11:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AE=A1=E6=A0=B8):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=BE=85=E5=AE=A1=E8=AE=A1=E6=95=B0=E7=BB=9F=E8=AE=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E6=94=AF=E6=92=91=E4=B8=AA=E4=BA=BA=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E8=8D=AF=E5=AE=A1=E6=A0=B8=E5=BE=BD=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 背景:个人中心「药审核」入口需要展示待审核任务数(红色徽标)。 该口径涉及 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,确认拦截生效。 --- .../yxe/controller/YxeAuditController.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/main/java/com/gxwebsoft/yxe/controller/YxeAuditController.java diff --git a/src/main/java/com/gxwebsoft/yxe/controller/YxeAuditController.java b/src/main/java/com/gxwebsoft/yxe/controller/YxeAuditController.java new file mode 100644 index 0000000..bd47a8e --- /dev/null +++ b/src/main/java/com/gxwebsoft/yxe/controller/YxeAuditController.java @@ -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() + .in(YxeUserTask::getCateId, (Object[]) MOVEMENT_CATE_IDS) + .eq(YxeUserTask::getStatus, TASK_STATUS_PENDING_AUDIT)); + long storeVisit = yxeUserTaskService.count(new LambdaQueryWrapper() + .eq(YxeUserTask::getCateId, STORE_VISIT_CATE_ID) + .eq(YxeUserTask::getStatus, TASK_STATUS_PENDING_AUDIT)); + long selfReport = yxeSelfReportService.count(new LambdaQueryWrapper() + .eq(YxeSelfReport::getStatus, STATUS_PENDING_AUDIT)); + long visitReport = yxeVisitReportService.count(new LambdaQueryWrapper() + .eq(YxeVisitReport::getStatus, STATUS_PENDING_AUDIT)); + long exchange = yxeShareService.count(new LambdaQueryWrapper() + .eq(YxeShare::getStatus, STATUS_PENDING_AUDIT)); + + Map 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 emptyCount() { + Map 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; + } +}