| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.dto.TCrmClinicAuditDTO; |
| | | import com.ruoyi.system.dto.TCrmClinicDTO; |
| | | import com.ruoyi.system.model.TCrmBranch; |
| | | import com.ruoyi.system.model.TCrmClinic; |
| | | import com.ruoyi.system.model.TCrmSalesperson; |
| | | import com.ruoyi.system.model.TCrmWarehouse; |
| | | import com.ruoyi.system.query.TCrmClinicQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TCrmClinicVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author xiaochen |
| | | * @since 2025-08-20 |
| | | */ |
| | | @Api(tags = "crm诊所管理") |
| | | @RestController |
| | | @RequestMapping("/t-crm-clinic") |
| | | public class TCrmClinicController { |
| | | |
| | | private final TCrmClinicService crmClinicService; |
| | | private final TCrmSupplierService crmSupplierService; |
| | | private final TCrmBranchService crmBranchService; |
| | | private final TCrmWarehouseService crmWarehouseService; |
| | | private final TCrmSalespersonService crmSalespersonService; |
| | | private final ISysUserService sysUserService; |
| | | @Autowired |
| | | public TCrmClinicController(TCrmClinicService crmClinicService, TCrmSupplierService crmSupplierService, TCrmBranchService crmBranchService, TCrmWarehouseService crmWarehouseService, TCrmSalespersonService crmSalespersonService, ISysUserService sysUserService) { |
| | | this.crmClinicService = crmClinicService; |
| | | this.crmSupplierService = crmSupplierService; |
| | | this.crmBranchService = crmBranchService; |
| | | this.crmWarehouseService = crmWarehouseService; |
| | | this.crmSalespersonService = crmSalespersonService; |
| | | this.sysUserService = sysUserService; |
| | | } |
| | | |
| | | /** |
| | | * 获取crm诊所管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取crm诊所管理分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | public R<PageInfo<TCrmClinicVO>> pageList(@RequestBody TCrmClinicQuery query) { |
| | | return R.ok(crmClinicService.pageList(query)); |
| | | } |
| | | |
| | | /** |
| | | * 获取crm诊所管理管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取crm诊所管理列表") |
| | | @PostMapping(value = "/list") |
| | | public R<List<TCrmClinic>> list() { |
| | | return R.ok(crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class) |
| | | .eq(TCrmClinic::getStatus,1) |
| | | .orderByDesc(TCrmClinic::getCreateTime))); |
| | | } |
| | | |
| | | /** |
| | | * 添加crm诊所管理管理 |
| | | */ |
| | | @Log(title = "crm诊所管理信息-新增crm诊所管理", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "添加crm诊所管理") |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> add(@Validated @RequestBody TCrmClinicDTO dto) { |
| | | return crmClinicService.addClinic(dto); |
| | | } |
| | | |
| | | /** |
| | | * 修改crm诊所管理 |
| | | */ |
| | | @Log(title = "crm诊所管理信息-修改crm诊所管理", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "修改crm诊所管理") |
| | | @PostMapping(value = "/update") |
| | | public R<Boolean> update(@Validated @RequestBody TCrmClinicDTO dto) { |
| | | return crmClinicService.updateClinic(dto); |
| | | } |
| | | |
| | | /** |
| | | * 查看crm诊所管理详情 |
| | | */ |
| | | @ApiOperation(value = "查看crm诊所管理详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TCrmClinicVO> getDetailById(@RequestParam String id) { |
| | | TCrmClinic crmSupplier = crmClinicService.getById(id); |
| | | TCrmClinicVO crmSupplierVO = new TCrmClinicVO(); |
| | | BeanUtils.copyProperties(crmSupplier, crmSupplierVO); |
| | | // 获取关联的分公司名称 |
| | | TCrmBranch crmBranch = crmBranchService.getById(crmSupplier.getBranchId()); |
| | | if(Objects.nonNull(crmBranch)){ |
| | | crmSupplierVO.setBranchName(crmBranch.getBranchName()); |
| | | } |
| | | // 获取关联的业务员名称 |
| | | TCrmSalesperson crmSalesperson = crmSalespersonService.getById(crmSupplier.getSalespersonId()); |
| | | if(Objects.nonNull(crmSalesperson)){ |
| | | crmSupplierVO.setSalespersonName(crmSalesperson.getSalespersonName()); |
| | | } |
| | | // 获取关联仓库 |
| | | TCrmWarehouse crmWarehouse = crmWarehouseService.getById(crmSupplier.getWarehouseId()); |
| | | if(Objects.nonNull(crmWarehouse)){ |
| | | crmSupplierVO.setWarehouseName(crmWarehouse.getWarehouseName()); |
| | | } |
| | | return R.ok(crmSupplierVO); |
| | | } |
| | | |
| | | /** |
| | | * 删除crm诊所管理 |
| | | */ |
| | | @Log(title = "crm诊所管理信息-删除crm诊所管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "删除crm诊所管理") |
| | | @DeleteMapping(value = "/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | // 删除账号 |
| | | TCrmClinic crmClinic = crmClinicService.getById(id); |
| | | sysUserService.deleteUserById(crmClinic.getUserId()); |
| | | return R.ok(crmClinicService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除crm诊所管理 |
| | | */ |
| | | @Log(title = "crm诊所管理信息-删除crm诊所管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "批量删除crm诊所管理") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | // 删除账号 |
| | | List<TCrmClinic> crmClinicList = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getId, ids)); |
| | | List<Long> userIds = crmClinicList.stream().map(TCrmClinic::getUserId).collect(Collectors.toList()); |
| | | sysUserService.deleteUserByIds(userIds); |
| | | return R.ok(crmClinicService.removeByIds(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除crm诊所管理 |
| | | */ |
| | | @Log(title = "crm诊所管理信息-诊所管理解冻冻结", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "诊所管理解冻冻结",notes = "状态 3=使用中 4=冻结") |
| | | @PutMapping(value = "/thawOrFreeze") |
| | | public R<Boolean> thawOrFreeze(@RequestParam(value = "id")String id, |
| | | @RequestParam(value = "status")Integer status) { |
| | | TCrmClinic crmClinic = crmClinicService.getById(id); |
| | | crmClinic.setStatus(status); |
| | | crmClinicService.updateById(crmClinic); |
| | | // 查询用户 |
| | | SysUser sysUser = sysUserService.selectUserById(crmClinic.getUserId()); |
| | | switch (status){ |
| | | case 3: |
| | | // 解冻 |
| | | sysUser.setStatus("0"); |
| | | sysUserService.updateUser(sysUser); |
| | | break; |
| | | case 4: |
| | | // 冻结 |
| | | sysUser.setStatus("1"); |
| | | sysUserService.updateUser(sysUser); |
| | | break; |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除crm诊所管理 |
| | | */ |
| | | @Log(title = "crm诊所管理信息-诊所管理审核", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "诊所管理审核",notes = "状态 1=待审核 2=已拒绝 3=使用中 4=冻结") |
| | | @PutMapping(value = "/auditClinic") |
| | | public R<Boolean> auditClinic(@RequestBody TCrmClinicAuditDTO dto) { |
| | | TCrmClinic crmClinic = crmClinicService.getById(dto.getId()); |
| | | crmClinic.setStatus(dto.getStatus()); |
| | | crmClinic.setAuditRemark(dto.getAuditRemark()); |
| | | crmClinicService.updateById(crmClinic); |
| | | // 查询用户 |
| | | if(dto.getStatus() == 3){ |
| | | SysUser sysUser = sysUserService.selectUserById(crmClinic.getUserId()); |
| | | sysUser.setDelFlag("0"); |
| | | sysUserService.updateUser(sysUser); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |