From d0fb900104015e62dbd20ea59e5602fb5a82ad4d Mon Sep 17 00:00:00 2001 From: aikai Date: Mon, 24 Feb 2025 15:07:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor(crm):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=BB=9F=E8=AE=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 CrmIndexController 中添加 userId 参数 - 更新 CrmIndexService 接口,增加 userId 参数 - 修改 CrmIndexServiceImpl 中的 getIndexCount 方法,支持 userId 参数 - 调整 getBrieCount 方法,添加 userId 参数 --- .../admin/crmindex/CrmIndexController.java | 6 +-- .../crm/service/crmindex/CrmIndexService.java | 2 +- .../service/crmindex/CrmIndexServiceImpl.java | 44 ++----------------- 3 files changed, 7 insertions(+), 45 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmindex/CrmIndexController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmindex/CrmIndexController.java index cf568387..9036a8f0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmindex/CrmIndexController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmindex/CrmIndexController.java @@ -25,10 +25,10 @@ public class CrmIndexController { @GetMapping("/getCount") @Operation(summary = "首页统计") - public CommonResult getCount(@RequestParam(name = "relation",defaultValue = "my",required=false) String relation) { - return success(crmIndexService.getIndexCount(relation)); + public CommonResult getCount(@RequestParam(name = "relation", defaultValue = "my", required = false) String relation, + @RequestParam(name = "userId", required = false) Long userId) { + return success(crmIndexService.getIndexCount(relation, userId)); } - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexService.java index 907ac0d6..869df5b4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexService.java @@ -9,6 +9,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.crmindex.vo.CrmIndexRespVO; */ public interface CrmIndexService { - CrmIndexRespVO getIndexCount(String relation); + CrmIndexRespVO getIndexCount(String relation,Long userId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexServiceImpl.java index 05fb4b4f..e77267c2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexServiceImpl.java @@ -71,47 +71,9 @@ public class CrmIndexServiceImpl implements CrmIndexService { @Override - public CrmIndexRespVO getIndexCount(String relation) { -// Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); -// Date todayStart = DateUtil.beginOfDay(new Date()); -// Date todayEnd = DateUtil.endOfDay(new Date()); -// Date day30 = DateUtil.offsetDay(new Date(),30); -// -// Long followCustomerCount = customerMapper.selectCount(new LambdaQueryWrapper() -// .between(CrmCustomerDO::getNextTime,todayStart,todayEnd).eq(CrmCustomerDO::getOwnerUserId,loginUserId)); -// Long followBusinessCount = businessMapper.selectCount(new LambdaQueryWrapper() -// .between(CrmBusinessDO::getNextTime,todayStart,todayEnd).eq(CrmBusinessDO::getOwnerUserId,loginUserId)); -// Long followCluesCount = crmCluesMapper.selectCount(new LambdaQueryWrapper() -// .between(CrmCluesDO::getNextTime,todayStart,todayEnd).eq(CrmCluesDO::getOwnerUserId,loginUserId)); -// Long contractDueCount = contractMapper.selectCount(new LambdaQueryWrapper() -// .between(CrmContractDO::getEndTime,todayStart,day30).eq(CrmContractDO::getOwnerUserId,loginUserId)); -// Long customerDueCount = 0L; -// Long contractReturnCount = contractMapper.selectCount(new LambdaQueryWrapper() -// .eq(CrmContractDO::getOwnerUserId,loginUserId).apply("money > return_money")); -// Long myInvoiceCount = crmInvoiceMapper.selectCount(new LambdaQueryWrapper() -// .eq(CrmInvoiceDO::getCreator,loginUserId)); -// Long productCount = storeProductMapper.selectCount(); -// -// Long contractCheckCount = contractMapper.selectCount(new LambdaQueryWrapper() -// .apply( "FIND_IN_SET ('" + loginUserId + "',flow_admin_id)")); -// Long receivablesCheckCount = contractReceivablesMapper.selectCount(new LambdaQueryWrapper() -// .apply( "FIND_IN_SET ('" + loginUserId + "',flow_admin_id)")); -// Long invoiceCheckCount = crmInvoiceMapper.selectCount(new LambdaQueryWrapper() -// .apply( "FIND_IN_SET ('" + loginUserId + "',flow_admin_id)")); - + public CrmIndexRespVO getIndexCount(String relation, Long userId) { return CrmIndexRespVO.builder() -// .followCustomerCount(followCustomerCount) -// .followBusinessCount(followBusinessCount) -// .followCluesCount(followCluesCount) -// .contractDueCount(contractDueCount) -// .customerDueCount(customerDueCount) -// .contractReturnCount(contractReturnCount) -// .myInvoiceCount(myInvoiceCount) -// .productCount(productCount) -// .contractCheckCount(contractCheckCount) -// .receivablesCheckCount(receivablesCheckCount) -// .invoiceCheckCount(invoiceCheckCount) - .brieCountVO(getBrieCount(relation)) + .brieCountVO(getBrieCount(relation, userId)) .build(); } @@ -120,7 +82,7 @@ public class CrmIndexServiceImpl implements CrmIndexService { * * @return */ - private BrieCountVO getBrieCount(String relation) { + private BrieCountVO getBrieCount(String relation, Long userId) { Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); Date todayStart = DateUtil.beginOfDay(new Date()); Date todayEnd = DateUtil.endOfDay(new Date()); From 74e439eb159e5e2abe2b922f5da8ada409a75081 Mon Sep 17 00:00:00 2001 From: aikai Date: Tue, 25 Feb 2025 14:44:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(crm):=20=E6=B7=BB=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BA=A7=E5=93=81=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 UserProductCountVO 类用于统计用户产品数量 - 在 CrmContractService接口中添加 getProductCount 方法 - 在 CrmContractServiceImpl 中实现 getProductCount 方法,通过 mapper 查询用户产品数量 - 在 CrmAchievementService 接口中添加 userId 参数用于业绩统计 - 在 CrmAchievementServiceImpl 中实现按用户统计业绩的功能 - 在 AchievementServiceImpl 中添加产品数量统计逻辑 - 在 CrmIndexServiceImpl 中实现下属用户业绩统计 --- .../module/bpm/api/oa/BpmOAContractApi.java | 1 + .../bpm/api/oa/BpmOAContractApiImpl.java | 2 +- .../bpm/dal/mysql/oa/BpmOAContractMapper.java | 9 +++-- .../bpm/service/oa/BpmOAContractService.java | 17 +++++++--- .../service/oa/BpmOAContractServiceImpl.java | 13 ++++---- .../yudao/module/hrm/enums/FlowStepEnum.java | 3 +- .../CrmAchievementController.java | 5 +-- .../admin/crmanalysis/vo/UserAchieveVO.java | 8 +++++ .../mysql/crmcontract/CrmContractMapper.java | 9 +++++ .../crmachievement/CrmAchievementService.java | 2 +- .../CrmAchievementServiceImpl.java | 19 ++++++++--- .../crmanalysis/AchievementServiceImpl.java | 17 ++++++++-- .../crmcontract/CrmContractService.java | 15 +++++++++ .../crmcontract/CrmContractServiceImpl.java | 14 +++++--- .../service/crmindex/CrmIndexServiceImpl.java | 6 +++- .../mapper/crmcontract/CrmContractMapper.xml | 33 +++++++++++++++++++ .../vo/UserProductCountVO.java | 28 ++++++++++++++++ .../HolidayUserRecordServiceImpl.java | 1 + 18 files changed, 169 insertions(+), 33 deletions(-) create mode 100644 yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/storeproductattrvalue/vo/UserProductCountVO.java diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/oa/BpmOAContractApi.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/oa/BpmOAContractApi.java index 9fce8b07..6bed12cd 100644 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/oa/BpmOAContractApi.java +++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/api/oa/BpmOAContractApi.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam; import java.time.LocalDateTime; import java.util.List; +import java.util.Map; @FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = @Tag(name = "RPC 服务 - 流程实例") diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/oa/BpmOAContractApiImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/oa/BpmOAContractApiImpl.java index b46c3eac..66a9011e 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/oa/BpmOAContractApiImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/api/oa/BpmOAContractApiImpl.java @@ -24,7 +24,7 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti */ @RestController @Validated -public class BpmOAContractApiImpl implements BpmOAContractApi{ +public class BpmOAContractApiImpl implements BpmOAContractApi { @Resource private BpmOAContractService contractService; diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOAContractMapper.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOAContractMapper.java index 98c6959b..8e52fb6c 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOAContractMapper.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/oa/BpmOAContractMapper.java @@ -18,7 +18,6 @@ import java.util.Objects; * 合同审批 Mapper * * @author 符溶馨 - */ @Mapper public interface BpmOAContractMapper extends BaseMapperX { @@ -39,17 +38,17 @@ public interface BpmOAContractMapper extends BaseMapperX { query.likeIfPresent(BpmOAContractDO::getCustomerName, pageReqVO.getCustomerName()); query.eqIfPresent(BpmOAContractDO::getStatus, pageReqVO.getStatus()); query.eqIfPresent(BpmOAContractDO::getResult, pageReqVO.getResult()); - query.apply(Objects.nonNull(pageReqVO.getSignatoryName()),"u.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getSignatoryName()); - query.apply(Objects.nonNull(pageReqVO.getCreateName()),"u1.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getCreateName()); + query.apply(Objects.nonNull(pageReqVO.getSignatoryName()), "u.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getSignatoryName()); + query.apply(Objects.nonNull(pageReqVO.getCreateName()), "u1.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getCreateName()); if ("my".equals(pageReqVO.getRelation())) { query.eq(BpmOAContractDO::getUserId, userId); - }else if ("sub".equals(pageReqVO.getRelation())){ + } else if ("sub".equals(pageReqVO.getRelation())) { query.innerJoin("(" + "\tSELECT DISTINCT\n" + "\t\tu.id \n" + "\tFROM\n" + "\t\tsystem_users u\n" + - "\t\tINNER JOIN system_dept d ON d.leader_user_id = "+ userId +"\n" + + "\t\tINNER JOIN system_dept d ON d.leader_user_id = " + userId + "\n" + "\t\tINNER JOIN system_dept d1 ON d1.flag LIKE CONCAT( '%', d.id, '-' ) \n" + "\t\tOR d1.flag LIKE CONCAT( '%-', d.id, '-%' ) \n" + "\t\tOR d1.flag LIKE CONCAT( '-', d.id, '%' ) \n" + diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOAContractService.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOAContractService.java index 7bf41c11..e90589ad 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOAContractService.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOAContractService.java @@ -18,7 +18,7 @@ public interface BpmOAContractService { /** * 创建合同申请 * - * @param userId 用户编号 + * @param userId 用户编号 * @param createReqVO 创建信息 * @return 编号 */ @@ -26,21 +26,23 @@ public interface BpmOAContractService { /** * 更新合同 + * * @param updateReqVO 更新信息 */ void updateContract(BpmOAContractDO updateReqVO); /** * 修改开票金额 + * * @param contractId 合同编号 - * @param amount 开票金额 + * @param amount 开票金额 */ void updateInvoiceMoney(Long contractId, BigDecimal amount); /** * 更新合同申请的状态 * - * @param id 编号 + * @param id 编号 * @param result 结果 */ void updateContractResult(String processInstanceId, Long id, Integer result); @@ -55,6 +57,7 @@ public interface BpmOAContractService { /** * 获得指定合同申请 + * * @param processInstanceId 流程实例编号 * @return 出差申请 */ @@ -62,6 +65,7 @@ public interface BpmOAContractService { /** * 获取当前用户所在部门的合同列表 + * * @param userIds 用户编号集合 * @return 合同列表 */ @@ -69,6 +73,7 @@ public interface BpmOAContractService { /** * 获得合同分页 + * * @param pageReqVO 分页参数 * @return 分页列表 */ @@ -76,6 +81,7 @@ public interface BpmOAContractService { /** * 获得指定流程实例的合同申请列表 + * * @param processInstanceIds 流程实例编号集合 * @return 合同列表 */ @@ -83,7 +89,8 @@ public interface BpmOAContractService { /** * 获得合同统计信息 - * @param userId 用户编号 + * + * @param userId 用户编号 * @param relation 查询类型 * @return 统计信息 */ @@ -100,6 +107,7 @@ public interface BpmOAContractService { /** * 获得合同列表 + * * @param respVO 参数列表 * @return 合同列表 */ @@ -107,6 +115,7 @@ public interface BpmOAContractService { /** * 获得指定客户合同列表 + * * @param customerId 客户编号 * @return 合同列表 */ diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOAContractServiceImpl.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOAContractServiceImpl.java index 509554d7..2eea172d 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOAContractServiceImpl.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/oa/BpmOAContractServiceImpl.java @@ -62,12 +62,11 @@ import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PRODUCT_S * OA 合同审批 Service 实现类 * * @author 符溶馨 - */ @Service @Validated @Slf4j -public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAContractService{ +public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAContractService { /** * OA 合同审批对应的流程定义 KEY @@ -130,7 +129,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC no = "HT" + now + String.format("%03d", Integer.parseInt(no) + 1); // redis 缓存订单号 stringRedisTemplate.opsForValue().increment(key, 1); - }else { + } else { no = "HT" + now + String.format("%03d", 1); // redis 缓存订单号 stringRedisTemplate.opsForValue().set(key, "1", 1, TimeUnit.DAYS); @@ -144,7 +143,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC } //插入OA 合同审批 - contractMapper.insert(contract) ; + contractMapper.insert(contract); // 发起 BPM 流程 Map processInstanceVariables = new HashMap<>(); @@ -161,10 +160,10 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC historyProcessInstanceService.createHistoryProcessInstance(processInstanceId, createReqVO.getProcessInstanceId()); } - List fileItems = createReqVO.getFileItems() ; + List fileItems = createReqVO.getFileItems(); //这里的逻辑,如果fileItems不为空,且有数据,那么说明是上传了附件的,则需要更工作流文件表对应的实例Id if (fileItems != null && !fileItems.isEmpty()) { - uploadBpmFileProcessInstanceId(processInstanceId,fileItems) ; + uploadBpmFileProcessInstanceId(processInstanceId, fileItems); } // 同步插入关联产品记录 @@ -316,7 +315,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC @Override public List getContractList(BpmOAContractVO respVO) { - Date[] dateArray = new Date[] { respVO.getStarTime(), respVO.getEndTime() }; + Date[] dateArray = new Date[]{respVO.getStarTime(), respVO.getEndTime()}; return contractMapper.selectList(new LambdaQueryWrapperX() .inIfPresent(BpmOAContractDO::getUserId, respVO.getUserId()) diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/hrm/enums/FlowStepEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/hrm/enums/FlowStepEnum.java index 93e1424b..ee3e075e 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/hrm/enums/FlowStepEnum.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/hrm/enums/FlowStepEnum.java @@ -11,7 +11,8 @@ import lombok.Getter; @AllArgsConstructor public enum FlowStepEnum { TYPE_2(2,"指定人员"), - TYPE_3(3,"指定部门"); + TYPE_3(3,"指定部门"), + TYPE_4(4,"下属"); private Integer value; private String desc; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmachievement/CrmAchievementController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmachievement/CrmAchievementController.java index 2de4c091..83484c81 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmachievement/CrmAchievementController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmachievement/CrmAchievementController.java @@ -83,7 +83,8 @@ public class CrmAchievementController { @Operation(summary = "业绩目标统计") public CommonResult getAchievementCount(@RequestParam(name = "type", required = false) Integer type, @RequestParam(name = "month", required = false) Integer month, - @RequestParam(name = "year", required = false) Integer year) { - return success(achievementService.getCount(type, year, month)); + @RequestParam(name = "year", required = false) Integer year, + @RequestParam(name = "userId", required = false) Long userId) { + return success(achievementService.getCount(type, year, month, userId)); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmanalysis/vo/UserAchieveVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmanalysis/vo/UserAchieveVO.java index 9c3662f6..8c019182 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmanalysis/vo/UserAchieveVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/crmanalysis/vo/UserAchieveVO.java @@ -1,9 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo; +import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.math.BigDecimal; +import java.util.List; @Schema(description = "管理后台 - 用户业绩分析信息 Response VO") @Data @@ -15,6 +17,9 @@ public class UserAchieveVO { @Schema(description = "用户名称") private String nickname; + @Schema(description = "产品数量") + private Integer productCount; + @Schema(description = "合同数量") private Long contractCount; @@ -33,4 +38,7 @@ public class UserAchieveVO { @Schema(description = "转客比率") private String cluesToCustomerPer; + @Schema(description = "产品列表") + private List productCountList; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/crmcontract/CrmContractMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/crmcontract/CrmContractMapper.java index eae69ea2..234bcaf1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/crmcontract/CrmContractMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/crmcontract/CrmContractMapper.java @@ -8,10 +8,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo.ContractVO; import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractRespVO; import cn.iocoder.yudao.module.crm.dal.dataobject.crmcontract.CrmContractDO; +import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.time.LocalDateTime; import java.util.List; /** @@ -54,4 +56,11 @@ public interface CrmContractMapper extends BaseMapperX { List selectContractTop(); + /** + * 获取用户合同产品数量 + * @param userIds + * @param createTime + * @return + */ + List getProductCount(@Param("userIds") List userIds, @Param("createTime") LocalDateTime[] createTime); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmachievement/CrmAchievementService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmachievement/CrmAchievementService.java index 68652897..cf3f258c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmachievement/CrmAchievementService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmachievement/CrmAchievementService.java @@ -70,6 +70,6 @@ public interface CrmAchievementService { * @param month 月份 * @return */ - AchieveCountRespVO getCount(Integer type, Integer year, Integer month); + AchieveCountRespVO getCount(Integer type, Integer year, Integer month, Long userId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmachievement/CrmAchievementServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmachievement/CrmAchievementServiceImpl.java index e9d00f9c..7e1296fd 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmachievement/CrmAchievementServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmachievement/CrmAchievementServiceImpl.java @@ -20,6 +20,7 @@ import cn.iocoder.yudao.module.bpm.api.oa.vo.receipt.BpmOAReceiptVO; import cn.iocoder.yudao.module.crm.controller.admin.crmachievement.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.crmachievement.CrmAchievementDO; import cn.iocoder.yudao.module.crm.dal.mysql.crmachievement.CrmAchievementMapper; +import cn.iocoder.yudao.module.crm.service.userlivetree.UserLiveTreeService; import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum; import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; @@ -64,6 +65,8 @@ public class CrmAchievementServiceImpl implements CrmAchievementService { @Resource private BpmOAReceiptApi receiptApi; + @Resource + private UserLiveTreeService userLiveTreeService; @Override @@ -147,7 +150,8 @@ public class CrmAchievementServiceImpl implements CrmAchievementService { /** * 批量插入操作 - * @param createReqVO 更新信息 + * + * @param createReqVO 更新信息 * @param achievements 更新信息 */ private void saveAchievementBatch(DeptAchieveSaveVO createReqVO, List achievements) { @@ -160,7 +164,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService { if (CollectionUtil.isEmpty(achievementOld)) { achievementMapper.insertBatch(achievements); - }else { + } else { // 获取之前业绩数据Map Map oldMap = convertMap(achievementOld, CrmAchievementDO::getTypeId); @@ -282,7 +286,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService { } @Override - public AchieveCountRespVO getCount(Integer type, Integer year, Integer month) { + public AchieveCountRespVO getCount(Integer type, Integer year, Integer month, Long userId) { // 获取当前登录用户编号 List userIds = new ArrayList<>(); @@ -290,7 +294,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService { if (FlowStepEnum.TYPE_2.getValue().equals(type)) { userIds.add(typeId); - } else { + } else if (FlowStepEnum.TYPE_3.getValue().equals(type)) { //部门 String deptId = Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getInfo().get(SecurityFrameworkUtils.INFO_KEY_DEPT_ID); typeId = deptId == null ? null : Long.valueOf(deptId); @@ -299,6 +303,13 @@ public class CrmAchievementServiceImpl implements CrmAchievementService { adminUserDOS = adminUserApi.getUserList(new AdminUserApiDTO().setDeptId(typeId).setNextDept(1)).getCheckedData(); } userIds = adminUserDOS.stream().map(AdminUserApiVO::getId).collect(Collectors.toList()); + } else { + if (userId != null) { + userIds.add(userId); + } else { + //下属 + userIds = userLiveTreeService.getItemIdsByUserId(typeId); + } } Date starTime = new Date(); Date endTime = new Date(); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmanalysis/AchievementServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmanalysis/AchievementServiceImpl.java index 1f9076a1..404bb808 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmanalysis/AchievementServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmanalysis/AchievementServiceImpl.java @@ -30,10 +30,12 @@ import cn.iocoder.yudao.module.crm.dal.mysql.crmcontract.CrmContractMapper; import cn.iocoder.yudao.module.crm.dal.mysql.crmcontractreceivables.CrmContractReceivablesMapper; import cn.iocoder.yudao.module.crm.dal.mysql.crmcustomer.CrmCustomerMapper; import cn.iocoder.yudao.module.crm.service.crmclues.CrmCluesService; +import cn.iocoder.yudao.module.crm.service.crmcontract.CrmContractService; import cn.iocoder.yudao.module.crm.service.userlivetree.UserLiveTreeService; import cn.iocoder.yudao.module.hrm.enums.ContractStatusEnum; import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum; import cn.iocoder.yudao.module.hrm.enums.RelationEnum; +import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO; import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.dto.DeptApiDTO; import cn.iocoder.yudao.module.system.api.dept.dto.DeptApiVO; @@ -87,7 +89,8 @@ public class AchievementServiceImpl implements AchievementService { private BpmOAReceiptApi receiptApi; @Resource private UserLiveTreeService userLiveTreeService; - + @Resource + private CrmContractService contractService; @Override public PageResult getAchievementPage(AchievementPageReqVO pageReqVO) { @@ -118,8 +121,13 @@ public class AchievementServiceImpl implements AchievementService { List cluesStatisticsRespVOS = cluesService.getCluesStatisticsByUserIds(userIds, pageReqVO.getCreateTime()); Map clusesMap = convertMap(cluesStatisticsRespVOS, CrmCluesStatisticsRespVO::getOwnerUserId); - pageResult1.getList().forEach(v -> { + // 统计用户产品数量 + List userProductCountVOS = contractService.getProductCount(userIds, pageReqVO.getCreateTime()); + // -- 根据用户分组 - + Map> userProductCount = userProductCountVOS.stream() + .collect(Collectors.groupingBy(UserProductCountVO::getUserId)); + pageResult1.getList().forEach(v -> { String per = "0"; // 设置合同数量 v.setContractCount(contractMap.get(v.getId()) != null ? Long.valueOf(contractMap.get(v.getId()).getCount()) : 0L); @@ -131,6 +139,11 @@ public class AchievementServiceImpl implements AchievementService { v.setCluesCount(clusesMap.get(v.getId()) != null ? Long.valueOf(clusesMap.get(v.getId()).getCount()) : 0L); // 设置转客数量 v.setCluesToCustomerCount(clusesMap.get(v.getId()) != null ? Long.valueOf(clusesMap.get(v.getId()).getSuccessCount()) : 0L); + // 产品列表 + v.setProductCountList(userProductCount.getOrDefault(v.getId(), Collections.emptyList())); + // 产品数量 + int sum = v.getProductCountList().stream().mapToInt(UserProductCountVO::getNums).sum(); + v.setProductCount(sum); // 设置转客比率 if (v.getCluesCount() > 0) { per = NumberUtil.round(NumberUtil.div(v.getCluesToCustomerCount(), v.getCluesCount()), 2) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmcontract/CrmContractService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmcontract/CrmContractService.java index 549b0929..6d66327f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmcontract/CrmContractService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmcontract/CrmContractService.java @@ -6,9 +6,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractPa import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractRespVO; import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractSaveReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.crmcontract.CrmContractProductDO; +import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO; import javax.validation.Valid; +import java.time.LocalDateTime; import java.util.List; +import java.util.Map; /** * 合同 Service 接口 @@ -67,20 +70,32 @@ public interface CrmContractService { /** * 生成合同编号 + * * @return */ String getCode(); /** * 审核合同 + * * @param checkInfoVO */ void check(CheckInfoVO checkInfoVO); /** * 创建合同产品 + * * @param createReqVO 创建信息 * @return 编号 */ void createProduct(List createReqVO); + + /** + * 获取用户合同产品数量 + * + * @param userIds + * @param createTime + * @return + */ + List getProductCount(List userIds, LocalDateTime[] createTime); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmcontract/CrmContractServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmcontract/CrmContractServiceImpl.java index 45aee239..094a11b8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmcontract/CrmContractServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmcontract/CrmContractServiceImpl.java @@ -32,7 +32,6 @@ import cn.iocoder.yudao.module.crm.dal.mysql.crmcustomercontacts.CrmCustomerCont import cn.iocoder.yudao.module.crm.dal.mysql.crmflow.CrmFlowMapper; import cn.iocoder.yudao.module.crm.dal.mysql.crmflow.CrmFlowStepMapper; import cn.iocoder.yudao.module.crm.dal.mysql.crmflowlog.CrmFlowLogMapper; -import cn.iocoder.yudao.module.crm.service.crmoperatelog.CrmOperatelogService; import cn.iocoder.yudao.module.crm.service.userlivetree.UserLiveTreeService; import cn.iocoder.yudao.module.hrm.enums.ContractStatusEnum; import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum; @@ -42,10 +41,12 @@ import cn.iocoder.yudao.module.product.api.storeproduct.StoreProductApi; import cn.iocoder.yudao.module.product.api.storeproductattrvalue.StoreProductAttrValueApi; import cn.iocoder.yudao.module.product.api.storeproductattrvalue.dto.StoreProductAttrValueApiDTO; import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.StoreProductAttrValueApiVO; +import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserApiDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserApiVO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.system.api.workovertime.vo.WorkOvertimeRuleItemApiVO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import lombok.extern.slf4j.Slf4j; @@ -58,11 +59,9 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -397,6 +396,11 @@ public class CrmContractServiceImpl implements CrmContractService { contractProductMapper.insertBatch(createReqVO); } + @Override + public List getProductCount(List userIds, LocalDateTime[] createTime) { + return contractMapper.getProductCount(userIds, createTime); + } + private void createContractProductList(Long contractId, List list) { List storeProductAttrValueList = new ArrayList<>(); if (CollUtil.isNotEmpty(list)) { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexServiceImpl.java index e77267c2..2c74a4aa 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/crmindex/CrmIndexServiceImpl.java @@ -95,7 +95,11 @@ public class CrmIndexServiceImpl implements CrmIndexService { if (RelationEnum.MY.getValue().equals(relation)) { ids.add(adminId); } else if (RelationEnum.SUB.getValue().equals(relation)) { - ids = userLiveTreeService.getItemIdsByUserId(adminId); + if (userId != null) { + ids.add(userId); + } else { + ids = userLiveTreeService.getItemIdsByUserId(adminId); + } } Long count01 = businessMapper.selectCount(new LambdaQueryWrapper() diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/crmcontract/CrmContractMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/crmcontract/CrmContractMapper.xml index 1e2a6290..e8262664 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/crmcontract/CrmContractMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/crmcontract/CrmContractMapper.xml @@ -81,4 +81,37 @@ money DESC LIMIT 10 + diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/storeproductattrvalue/vo/UserProductCountVO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/storeproductattrvalue/vo/UserProductCountVO.java new file mode 100644 index 00000000..1c4b0989 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/storeproductattrvalue/vo/UserProductCountVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class UserProductCountVO { + @Schema(description = "用户编号") + private Long userId; + @Schema(description = "产品数量") + private Integer nums; + @Schema(description = "产品id") + private Long productId; + @Schema(description = "产品名称") + private String name; + @Schema(description = "商品属性") + private String productAttrUnique; + @Schema(description = "产品单价") + private BigDecimal price; + @Schema(description = "折扣") + private BigDecimal discount; + @Schema(description = "小计(折扣后价格)") + private BigDecimal subtotal; + @Schema(description = "备注") + private String remarks; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/holiday/holidayuserrecord/HolidayUserRecordServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/holiday/holidayuserrecord/HolidayUserRecordServiceImpl.java index abff318e..484217eb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/holiday/holidayuserrecord/HolidayUserRecordServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/holiday/holidayuserrecord/HolidayUserRecordServiceImpl.java @@ -434,6 +434,7 @@ public class HolidayUserRecordServiceImpl implements HolidayUserRecordService { LocalDateTime now, String remark, Integer direction, String reason, Boolean recordZero) { BigDecimal quota = userQuotaMap.get(userId); // -- 如果是0的话就不记录了 -- 如果不记录0 并且是0 直接return + log.info("假期额度分配数量quota为:{},recordZero为:{}", quota, recordZero); if (quota == null || (BigDecimal.ZERO.compareTo(quota) == 0 && !recordZero)) { return; } From 309b9804b486aff7cea8de08953d297da0e0ad32 Mon Sep 17 00:00:00 2001 From: aikai Date: Fri, 28 Feb 2025 10:46:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=81=87=E6=9C=9F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/crmcontract/CrmContractMapper.xml | 2 +- .../holidayuserrecord/HolidayUserRecordServiceImpl.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/crmcontract/CrmContractMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/crmcontract/CrmContractMapper.xml index e8262664..72815c3f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/crmcontract/CrmContractMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/crmcontract/CrmContractMapper.xml @@ -98,7 +98,7 @@ a.deleted = 0 and b.deleted = 0 - + AND a.owner_user_id in #{id} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/holiday/holidayuserrecord/HolidayUserRecordServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/holiday/holidayuserrecord/HolidayUserRecordServiceImpl.java index 484217eb..04a81d67 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/holiday/holidayuserrecord/HolidayUserRecordServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/holiday/holidayuserrecord/HolidayUserRecordServiceImpl.java @@ -281,9 +281,11 @@ public class HolidayUserRecordServiceImpl implements HolidayUserRecordService { String year = String.valueOf(now.getYear()); newHolidayUserDOList.forEach( a -> { - newHolidayUserEmploymentRecordDOList.add(new HolidayUserEmploymentRecordDO().setUserId(a.getUserId()) - .setHolidaySettingId(holidaySetting.getId()) - .setYearNum(year)); + if (BigDecimal.ZERO.compareTo(a.getHolidayBalance()) > 0) { + newHolidayUserEmploymentRecordDOList.add(new HolidayUserEmploymentRecordDO().setUserId(a.getUserId()) + .setHolidaySettingId(holidaySetting.getId()) + .setYearNum(year)); + } } ); if (CollUtil.isNotEmpty(newHolidayUserEmploymentRecordDOList)) { @@ -300,6 +302,7 @@ public class HolidayUserRecordServiceImpl implements HolidayUserRecordService { List users = this.getUsersByRange(holidaySetting, holidaySettingRangeDOS); // -- 计算获取每个人的假期额度 Map userQuotaMap = this.getQuotaMap(users, holidayBalanceSettingDO, holidayWorkingAgeDOS); + log.info("计算获取每个人的假期额度 userQuotaMap:{}", userQuotaMap); // -- 获取用户的假期表 List userIds = users.stream().map(AdminUserDO::getId).collect(Collectors.toList()); Map userMap = users.stream().collect(Collectors.toMap(AdminUserDO::getId, a -> a));