From 447985592c29f9e5c02a783088b1abf2112c032a Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 05 十二月 2025 11:15:30 +0800
Subject: [PATCH] 修改分公司

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
index 98049f6..df5f843 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
@@ -13,6 +13,7 @@
 import com.ruoyi.common.utils.WebUtils;
 import com.ruoyi.framework.web.service.TokenService;
 import com.ruoyi.system.dto.TCrmBranchDTO;
+import com.ruoyi.system.dto.UnbindDTO;
 import com.ruoyi.system.export.TCrmBranchExport;
 import com.ruoyi.system.export.TSysAppUserClinicExport;
 import com.ruoyi.system.export.TSysAppUserExport;
@@ -59,9 +60,10 @@
     private final TCrmChangePointsService crmChangePointsService;
     private final TCrmPositionService crmPositionService;
     private final TCrmSalespersonService crmSalespersonService;
+    private final TCrmBranchLiftService crmBranchLiftService;
     private final TokenService tokenService;
     @Autowired
-    public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmPositionService crmPositionService, TCrmSalespersonService crmSalespersonService, TokenService tokenService) {
+    public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmPositionService crmPositionService, TCrmSalespersonService crmSalespersonService, TCrmBranchLiftService crmBranchLiftService, TokenService tokenService) {
         this.crmBranchService = crmBranchService;
         this.crmBranchAreaService = crmBranchAreaService;
         this.crmBranchSalaryService = crmBranchSalaryService;
@@ -69,6 +71,7 @@
         this.crmChangePointsService = crmChangePointsService;
         this.crmPositionService = crmPositionService;
         this.crmSalespersonService = crmSalespersonService;
+        this.crmBranchLiftService = crmBranchLiftService;
         this.tokenService = tokenService;
     }
 
@@ -78,6 +81,8 @@
     @ApiOperation(value = "获取crm分公司管理分页列表")
     @PostMapping(value = "/pageList")
     public R<PageInfo<TCrmBranchVO>> pageList(@RequestBody TCrmBranchQuery query) {
+        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+        query.setRoleType(roleType);
         return R.ok(crmBranchService.pageList(query));
     }
 
@@ -102,7 +107,9 @@
                 wrapper.eq(TCrmBranch::getId, crmSalesperson.getBranchId());
             }
         }
-        wrapper.eq(TCrmBranch::getStatus,1).orderByDesc(TCrmBranch::getCreateTime);
+        wrapper.eq(TCrmBranch::getStatus,1)
+                .eq(TCrmBranch::getAuditStatus,2)
+                .orderByDesc(TCrmBranch::getCreateTime);
         return R.ok(crmBranchService.list(wrapper));
     }
 
@@ -113,6 +120,13 @@
     @ApiOperation(value = "添加crm分公司管理")
     @PostMapping(value = "/add")
     public R<Boolean> add(@Validated @RequestBody TCrmBranchDTO dto) {
+        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+        if (roleType == 2) {
+            dto.setAuditStatus(1);
+        }
+        if (roleType == 1) {
+            dto.setAuditStatus(2);
+        }
         return crmBranchService.addBranch(dto);
     }
 
@@ -259,6 +273,8 @@
     @ApiOperation(value = "分公司管理信息导出")
     @PostMapping("/exportList")
     public void exportList(@RequestBody TCrmBranchQuery query){
+        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+        query.setRoleType(roleType);
         List<TCrmBranchExport> crmBranchExports = crmBranchService.exportList(query);
         Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TCrmBranchExport.class, crmBranchExports);
         HttpServletResponse response = WebUtils.response();
@@ -285,5 +301,28 @@
         }
     }
 
+    /**
+     * 解除绑定
+     */
+    @ApiOperation(value = "crm分公司管理信息-解除绑定", notes = "clinicId:诊所id")
+    @GetMapping(value = "/unbind")
+    public R<String> unbind(@RequestBody UnbindDTO dto) {
+        Long userId = tokenService.getLoginUser().getUserId();
+        TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class)
+                .eq(TCrmBranch::getUserId, userId)
+                .last("LIMIT 1"));
+        if(crmBranch.getPersonType() != 1){
+            return R.fail("仅负责人可操作解除绑定");
+        }
+
+        TCrmBranchLift crmBranchLift = new TCrmBranchLift();
+        crmBranchLift.setBranchId(crmBranch.getId());
+        crmBranchLift.setChargePhone(dto.getChargePhone());
+        crmBranchLift.setLiftReason(dto.getLiftReason());
+        crmBranchLiftService.save(crmBranchLift);
+
+        return R.ok();
+    }
+
 }
 

--
Gitblit v1.7.1