feat(crm): 添加用户产品数量统计功能
- 新增 UserProductCountVO 类用于统计用户产品数量 - 在 CrmContractService接口中添加 getProductCount 方法 - 在 CrmContractServiceImpl 中实现 getProductCount 方法,通过 mapper 查询用户产品数量 - 在 CrmAchievementService 接口中添加 userId 参数用于业绩统计 - 在 CrmAchievementServiceImpl 中实现按用户统计业绩的功能 - 在 AchievementServiceImpl 中添加产品数量统计逻辑 - 在 CrmIndexServiceImpl 中实现下属用户业绩统计
This commit is contained in:
parent
c0d3d869aa
commit
74e439eb15
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||||
@Tag(name = "RPC 服务 - 流程实例")
|
@Tag(name = "RPC 服务 - 流程实例")
|
||||||
|
@ -24,7 +24,7 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@Validated
|
@Validated
|
||||||
public class BpmOAContractApiImpl implements BpmOAContractApi{
|
public class BpmOAContractApiImpl implements BpmOAContractApi {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BpmOAContractService contractService;
|
private BpmOAContractService contractService;
|
||||||
|
@ -18,7 +18,6 @@ import java.util.Objects;
|
|||||||
* 合同审批 Mapper
|
* 合同审批 Mapper
|
||||||
*
|
*
|
||||||
* @author 符溶馨
|
* @author 符溶馨
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BpmOAContractMapper extends BaseMapperX<BpmOAContractDO> {
|
public interface BpmOAContractMapper extends BaseMapperX<BpmOAContractDO> {
|
||||||
@ -39,17 +38,17 @@ public interface BpmOAContractMapper extends BaseMapperX<BpmOAContractDO> {
|
|||||||
query.likeIfPresent(BpmOAContractDO::getCustomerName, pageReqVO.getCustomerName());
|
query.likeIfPresent(BpmOAContractDO::getCustomerName, pageReqVO.getCustomerName());
|
||||||
query.eqIfPresent(BpmOAContractDO::getStatus, pageReqVO.getStatus());
|
query.eqIfPresent(BpmOAContractDO::getStatus, pageReqVO.getStatus());
|
||||||
query.eqIfPresent(BpmOAContractDO::getResult, pageReqVO.getResult());
|
query.eqIfPresent(BpmOAContractDO::getResult, pageReqVO.getResult());
|
||||||
query.apply(Objects.nonNull(pageReqVO.getSignatoryName()),"u.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getSignatoryName());
|
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.getCreateName()), "u1.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getCreateName());
|
||||||
if ("my".equals(pageReqVO.getRelation())) {
|
if ("my".equals(pageReqVO.getRelation())) {
|
||||||
query.eq(BpmOAContractDO::getUserId, userId);
|
query.eq(BpmOAContractDO::getUserId, userId);
|
||||||
}else if ("sub".equals(pageReqVO.getRelation())){
|
} else if ("sub".equals(pageReqVO.getRelation())) {
|
||||||
query.innerJoin("(" +
|
query.innerJoin("(" +
|
||||||
"\tSELECT DISTINCT\n" +
|
"\tSELECT DISTINCT\n" +
|
||||||
"\t\tu.id \n" +
|
"\t\tu.id \n" +
|
||||||
"\tFROM\n" +
|
"\tFROM\n" +
|
||||||
"\t\tsystem_users u\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\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" +
|
||||||
"\t\tOR d1.flag LIKE CONCAT( '-', d.id, '%' ) \n" +
|
"\t\tOR d1.flag LIKE CONCAT( '-', d.id, '%' ) \n" +
|
||||||
|
@ -18,7 +18,7 @@ public interface BpmOAContractService {
|
|||||||
/**
|
/**
|
||||||
* 创建合同申请
|
* 创建合同申请
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
@ -26,21 +26,23 @@ public interface BpmOAContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新合同
|
* 更新合同
|
||||||
|
*
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateContract(BpmOAContractDO updateReqVO);
|
void updateContract(BpmOAContractDO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改开票金额
|
* 修改开票金额
|
||||||
|
*
|
||||||
* @param contractId 合同编号
|
* @param contractId 合同编号
|
||||||
* @param amount 开票金额
|
* @param amount 开票金额
|
||||||
*/
|
*/
|
||||||
void updateInvoiceMoney(Long contractId, BigDecimal amount);
|
void updateInvoiceMoney(Long contractId, BigDecimal amount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新合同申请的状态
|
* 更新合同申请的状态
|
||||||
*
|
*
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @param result 结果
|
* @param result 结果
|
||||||
*/
|
*/
|
||||||
void updateContractResult(String processInstanceId, Long id, Integer result);
|
void updateContractResult(String processInstanceId, Long id, Integer result);
|
||||||
@ -55,6 +57,7 @@ public interface BpmOAContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得指定合同申请
|
* 获得指定合同申请
|
||||||
|
*
|
||||||
* @param processInstanceId 流程实例编号
|
* @param processInstanceId 流程实例编号
|
||||||
* @return 出差申请
|
* @return 出差申请
|
||||||
*/
|
*/
|
||||||
@ -62,6 +65,7 @@ public interface BpmOAContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户所在部门的合同列表
|
* 获取当前用户所在部门的合同列表
|
||||||
|
*
|
||||||
* @param userIds 用户编号集合
|
* @param userIds 用户编号集合
|
||||||
* @return 合同列表
|
* @return 合同列表
|
||||||
*/
|
*/
|
||||||
@ -69,6 +73,7 @@ public interface BpmOAContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得合同分页
|
* 获得合同分页
|
||||||
|
*
|
||||||
* @param pageReqVO 分页参数
|
* @param pageReqVO 分页参数
|
||||||
* @return 分页列表
|
* @return 分页列表
|
||||||
*/
|
*/
|
||||||
@ -76,6 +81,7 @@ public interface BpmOAContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得指定流程实例的合同申请列表
|
* 获得指定流程实例的合同申请列表
|
||||||
|
*
|
||||||
* @param processInstanceIds 流程实例编号集合
|
* @param processInstanceIds 流程实例编号集合
|
||||||
* @return 合同列表
|
* @return 合同列表
|
||||||
*/
|
*/
|
||||||
@ -83,7 +89,8 @@ public interface BpmOAContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得合同统计信息
|
* 获得合同统计信息
|
||||||
* @param userId 用户编号
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
* @param relation 查询类型
|
* @param relation 查询类型
|
||||||
* @return 统计信息
|
* @return 统计信息
|
||||||
*/
|
*/
|
||||||
@ -100,6 +107,7 @@ public interface BpmOAContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得合同列表
|
* 获得合同列表
|
||||||
|
*
|
||||||
* @param respVO 参数列表
|
* @param respVO 参数列表
|
||||||
* @return 合同列表
|
* @return 合同列表
|
||||||
*/
|
*/
|
||||||
@ -107,6 +115,7 @@ public interface BpmOAContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得指定客户合同列表
|
* 获得指定客户合同列表
|
||||||
|
*
|
||||||
* @param customerId 客户编号
|
* @param customerId 客户编号
|
||||||
* @return 合同列表
|
* @return 合同列表
|
||||||
*/
|
*/
|
||||||
|
@ -62,12 +62,11 @@ import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PRODUCT_S
|
|||||||
* OA 合同审批 Service 实现类
|
* OA 合同审批 Service 实现类
|
||||||
*
|
*
|
||||||
* @author 符溶馨
|
* @author 符溶馨
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAContractService{
|
public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAContractService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OA 合同审批对应的流程定义 KEY
|
* OA 合同审批对应的流程定义 KEY
|
||||||
@ -130,7 +129,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
|
|||||||
no = "HT" + now + String.format("%03d", Integer.parseInt(no) + 1);
|
no = "HT" + now + String.format("%03d", Integer.parseInt(no) + 1);
|
||||||
// redis 缓存订单号
|
// redis 缓存订单号
|
||||||
stringRedisTemplate.opsForValue().increment(key, 1);
|
stringRedisTemplate.opsForValue().increment(key, 1);
|
||||||
}else {
|
} else {
|
||||||
no = "HT" + now + String.format("%03d", 1);
|
no = "HT" + now + String.format("%03d", 1);
|
||||||
// redis 缓存订单号
|
// redis 缓存订单号
|
||||||
stringRedisTemplate.opsForValue().set(key, "1", 1, TimeUnit.DAYS);
|
stringRedisTemplate.opsForValue().set(key, "1", 1, TimeUnit.DAYS);
|
||||||
@ -144,7 +143,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
|
|||||||
}
|
}
|
||||||
|
|
||||||
//插入OA 合同审批
|
//插入OA 合同审批
|
||||||
contractMapper.insert(contract) ;
|
contractMapper.insert(contract);
|
||||||
|
|
||||||
// 发起 BPM 流程
|
// 发起 BPM 流程
|
||||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||||
@ -161,10 +160,10 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
|
|||||||
historyProcessInstanceService.createHistoryProcessInstance(processInstanceId, createReqVO.getProcessInstanceId());
|
historyProcessInstanceService.createHistoryProcessInstance(processInstanceId, createReqVO.getProcessInstanceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<UploadUserFile> fileItems = createReqVO.getFileItems() ;
|
List<UploadUserFile> fileItems = createReqVO.getFileItems();
|
||||||
//这里的逻辑,如果fileItems不为空,且有数据,那么说明是上传了附件的,则需要更工作流文件表对应的实例Id
|
//这里的逻辑,如果fileItems不为空,且有数据,那么说明是上传了附件的,则需要更工作流文件表对应的实例Id
|
||||||
if (fileItems != null && !fileItems.isEmpty()) {
|
if (fileItems != null && !fileItems.isEmpty()) {
|
||||||
uploadBpmFileProcessInstanceId(processInstanceId,fileItems) ;
|
uploadBpmFileProcessInstanceId(processInstanceId, fileItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同步插入关联产品记录
|
// 同步插入关联产品记录
|
||||||
@ -316,7 +315,7 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
|
|||||||
@Override
|
@Override
|
||||||
public List<BpmOAContractDO> getContractList(BpmOAContractVO respVO) {
|
public List<BpmOAContractDO> getContractList(BpmOAContractVO respVO) {
|
||||||
|
|
||||||
Date[] dateArray = new Date[] { respVO.getStarTime(), respVO.getEndTime() };
|
Date[] dateArray = new Date[]{respVO.getStarTime(), respVO.getEndTime()};
|
||||||
|
|
||||||
return contractMapper.selectList(new LambdaQueryWrapperX<BpmOAContractDO>()
|
return contractMapper.selectList(new LambdaQueryWrapperX<BpmOAContractDO>()
|
||||||
.inIfPresent(BpmOAContractDO::getUserId, respVO.getUserId())
|
.inIfPresent(BpmOAContractDO::getUserId, respVO.getUserId())
|
||||||
|
@ -11,7 +11,8 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum FlowStepEnum {
|
public enum FlowStepEnum {
|
||||||
TYPE_2(2,"指定人员"),
|
TYPE_2(2,"指定人员"),
|
||||||
TYPE_3(3,"指定部门");
|
TYPE_3(3,"指定部门"),
|
||||||
|
TYPE_4(4,"下属");
|
||||||
|
|
||||||
private Integer value;
|
private Integer value;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
@ -83,7 +83,8 @@ public class CrmAchievementController {
|
|||||||
@Operation(summary = "业绩目标统计")
|
@Operation(summary = "业绩目标统计")
|
||||||
public CommonResult<AchieveCountRespVO> getAchievementCount(@RequestParam(name = "type", required = false) Integer type,
|
public CommonResult<AchieveCountRespVO> getAchievementCount(@RequestParam(name = "type", required = false) Integer type,
|
||||||
@RequestParam(name = "month", required = false) Integer month,
|
@RequestParam(name = "month", required = false) Integer month,
|
||||||
@RequestParam(name = "year", required = false) Integer year) {
|
@RequestParam(name = "year", required = false) Integer year,
|
||||||
return success(achievementService.getCount(type, year, month));
|
@RequestParam(name = "userId", required = false) Long userId) {
|
||||||
|
return success(achievementService.getCount(type, year, month, userId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo;
|
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 用户业绩分析信息 Response VO")
|
@Schema(description = "管理后台 - 用户业绩分析信息 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ -15,6 +17,9 @@ public class UserAchieveVO {
|
|||||||
@Schema(description = "用户名称")
|
@Schema(description = "用户名称")
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
|
@Schema(description = "产品数量")
|
||||||
|
private Integer productCount;
|
||||||
|
|
||||||
@Schema(description = "合同数量")
|
@Schema(description = "合同数量")
|
||||||
private Long contractCount;
|
private Long contractCount;
|
||||||
|
|
||||||
@ -33,4 +38,7 @@ public class UserAchieveVO {
|
|||||||
@Schema(description = "转客比率")
|
@Schema(description = "转客比率")
|
||||||
private String cluesToCustomerPer;
|
private String cluesToCustomerPer;
|
||||||
|
|
||||||
|
@Schema(description = "产品列表")
|
||||||
|
private List<UserProductCountVO> productCountList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.CrmContractPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractRespVO;
|
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.crm.dal.dataobject.crmcontract.CrmContractDO;
|
||||||
|
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,4 +56,11 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
|||||||
|
|
||||||
List<ContractVO> selectContractTop();
|
List<ContractVO> selectContractTop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户合同产品数量
|
||||||
|
* @param userIds
|
||||||
|
* @param createTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<UserProductCountVO> getProductCount(@Param("userIds") List<Long> userIds, @Param("createTime") LocalDateTime[] createTime);
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,6 @@ public interface CrmAchievementService {
|
|||||||
* @param month 月份
|
* @param month 月份
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AchieveCountRespVO getCount(Integer type, Integer year, Integer month);
|
AchieveCountRespVO getCount(Integer type, Integer year, Integer month, Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.controller.admin.crmachievement.vo.*;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.crmachievement.CrmAchievementDO;
|
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.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.hrm.enums.FlowStepEnum;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||||
@ -64,6 +65,8 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BpmOAReceiptApi receiptApi;
|
private BpmOAReceiptApi receiptApi;
|
||||||
|
@Resource
|
||||||
|
private UserLiveTreeService userLiveTreeService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -147,7 +150,8 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入操作
|
* 批量插入操作
|
||||||
* @param createReqVO 更新信息
|
*
|
||||||
|
* @param createReqVO 更新信息
|
||||||
* @param achievements 更新信息
|
* @param achievements 更新信息
|
||||||
*/
|
*/
|
||||||
private void saveAchievementBatch(DeptAchieveSaveVO createReqVO, List<CrmAchievementDO> achievements) {
|
private void saveAchievementBatch(DeptAchieveSaveVO createReqVO, List<CrmAchievementDO> achievements) {
|
||||||
@ -160,7 +164,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
|||||||
if (CollectionUtil.isEmpty(achievementOld)) {
|
if (CollectionUtil.isEmpty(achievementOld)) {
|
||||||
|
|
||||||
achievementMapper.insertBatch(achievements);
|
achievementMapper.insertBatch(achievements);
|
||||||
}else {
|
} else {
|
||||||
|
|
||||||
// 获取之前业绩数据Map
|
// 获取之前业绩数据Map
|
||||||
Map<Long, CrmAchievementDO> oldMap = convertMap(achievementOld, CrmAchievementDO::getTypeId);
|
Map<Long, CrmAchievementDO> oldMap = convertMap(achievementOld, CrmAchievementDO::getTypeId);
|
||||||
@ -282,7 +286,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AchieveCountRespVO getCount(Integer type, Integer year, Integer month) {
|
public AchieveCountRespVO getCount(Integer type, Integer year, Integer month, Long userId) {
|
||||||
|
|
||||||
// 获取当前登录用户编号
|
// 获取当前登录用户编号
|
||||||
List<Long> userIds = new ArrayList<>();
|
List<Long> userIds = new ArrayList<>();
|
||||||
@ -290,7 +294,7 @@ public class CrmAchievementServiceImpl implements CrmAchievementService {
|
|||||||
|
|
||||||
if (FlowStepEnum.TYPE_2.getValue().equals(type)) {
|
if (FlowStepEnum.TYPE_2.getValue().equals(type)) {
|
||||||
userIds.add(typeId);
|
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);
|
String deptId = Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getInfo().get(SecurityFrameworkUtils.INFO_KEY_DEPT_ID);
|
||||||
typeId = deptId == null ? null : Long.valueOf(deptId);
|
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();
|
adminUserDOS = adminUserApi.getUserList(new AdminUserApiDTO().setDeptId(typeId).setNextDept(1)).getCheckedData();
|
||||||
}
|
}
|
||||||
userIds = adminUserDOS.stream().map(AdminUserApiVO::getId).collect(Collectors.toList());
|
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 starTime = new Date();
|
||||||
Date endTime = new Date();
|
Date endTime = new Date();
|
||||||
|
@ -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.crmcontractreceivables.CrmContractReceivablesMapper;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.crmcustomer.CrmCustomerMapper;
|
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.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.crm.service.userlivetree.UserLiveTreeService;
|
||||||
import cn.iocoder.yudao.module.hrm.enums.ContractStatusEnum;
|
import cn.iocoder.yudao.module.hrm.enums.ContractStatusEnum;
|
||||||
import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum;
|
import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum;
|
||||||
import cn.iocoder.yudao.module.hrm.enums.RelationEnum;
|
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.DeptApi;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptApiDTO;
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptApiDTO;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptApiVO;
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptApiVO;
|
||||||
@ -87,7 +89,8 @@ public class AchievementServiceImpl implements AchievementService {
|
|||||||
private BpmOAReceiptApi receiptApi;
|
private BpmOAReceiptApi receiptApi;
|
||||||
@Resource
|
@Resource
|
||||||
private UserLiveTreeService userLiveTreeService;
|
private UserLiveTreeService userLiveTreeService;
|
||||||
|
@Resource
|
||||||
|
private CrmContractService contractService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<UserAchieveVO> getAchievementPage(AchievementPageReqVO pageReqVO) {
|
public PageResult<UserAchieveVO> getAchievementPage(AchievementPageReqVO pageReqVO) {
|
||||||
@ -118,8 +121,13 @@ public class AchievementServiceImpl implements AchievementService {
|
|||||||
List<CrmCluesStatisticsRespVO> cluesStatisticsRespVOS = cluesService.getCluesStatisticsByUserIds(userIds, pageReqVO.getCreateTime());
|
List<CrmCluesStatisticsRespVO> cluesStatisticsRespVOS = cluesService.getCluesStatisticsByUserIds(userIds, pageReqVO.getCreateTime());
|
||||||
Map<Long, CrmCluesStatisticsRespVO> clusesMap = convertMap(cluesStatisticsRespVOS, CrmCluesStatisticsRespVO::getOwnerUserId);
|
Map<Long, CrmCluesStatisticsRespVO> clusesMap = convertMap(cluesStatisticsRespVOS, CrmCluesStatisticsRespVO::getOwnerUserId);
|
||||||
|
|
||||||
pageResult1.getList().forEach(v -> {
|
// 统计用户产品数量
|
||||||
|
List<UserProductCountVO> userProductCountVOS = contractService.getProductCount(userIds, pageReqVO.getCreateTime());
|
||||||
|
// -- 根据用户分组 -
|
||||||
|
Map<Long, List<UserProductCountVO>> userProductCount = userProductCountVOS.stream()
|
||||||
|
.collect(Collectors.groupingBy(UserProductCountVO::getUserId));
|
||||||
|
|
||||||
|
pageResult1.getList().forEach(v -> {
|
||||||
String per = "0";
|
String per = "0";
|
||||||
// 设置合同数量
|
// 设置合同数量
|
||||||
v.setContractCount(contractMap.get(v.getId()) != null ? Long.valueOf(contractMap.get(v.getId()).getCount()) : 0L);
|
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.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.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) {
|
if (v.getCluesCount() > 0) {
|
||||||
per = NumberUtil.round(NumberUtil.div(v.getCluesToCustomerCount(), v.getCluesCount()), 2)
|
per = NumberUtil.round(NumberUtil.div(v.getCluesToCustomerCount(), v.getCluesCount()), 2)
|
||||||
|
@ -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.CrmContractRespVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.crmcontract.vo.CrmContractSaveReqVO;
|
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.crm.dal.dataobject.crmcontract.CrmContractProductDO;
|
||||||
|
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合同 Service 接口
|
* 合同 Service 接口
|
||||||
@ -67,20 +70,32 @@ public interface CrmContractService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成合同编号
|
* 生成合同编号
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getCode();
|
String getCode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审核合同
|
* 审核合同
|
||||||
|
*
|
||||||
* @param checkInfoVO
|
* @param checkInfoVO
|
||||||
*/
|
*/
|
||||||
void check(CheckInfoVO checkInfoVO);
|
void check(CheckInfoVO checkInfoVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建合同产品
|
* 创建合同产品
|
||||||
|
*
|
||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
void createProduct(List<CrmContractProductDO> createReqVO);
|
void createProduct(List<CrmContractProductDO> createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户合同产品数量
|
||||||
|
*
|
||||||
|
* @param userIds
|
||||||
|
* @param createTime
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<UserProductCountVO> getProductCount(List<Long> userIds, LocalDateTime[] createTime);
|
||||||
}
|
}
|
||||||
|
@ -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.CrmFlowMapper;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.crmflow.CrmFlowStepMapper;
|
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.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.crm.service.userlivetree.UserLiveTreeService;
|
||||||
import cn.iocoder.yudao.module.hrm.enums.ContractStatusEnum;
|
import cn.iocoder.yudao.module.hrm.enums.ContractStatusEnum;
|
||||||
import cn.iocoder.yudao.module.hrm.enums.FlowStepEnum;
|
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.StoreProductAttrValueApi;
|
||||||
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.dto.StoreProductAttrValueApiDTO;
|
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.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.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserApiDTO;
|
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.AdminUserApiVO;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
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.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -58,11 +59,9 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -397,6 +396,11 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
contractProductMapper.insertBatch(createReqVO);
|
contractProductMapper.insertBatch(createReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserProductCountVO> getProductCount(List<Long> userIds, LocalDateTime[] createTime) {
|
||||||
|
return contractMapper.getProductCount(userIds, createTime);
|
||||||
|
}
|
||||||
|
|
||||||
private void createContractProductList(Long contractId, List<CrmContractProductDO> list) {
|
private void createContractProductList(Long contractId, List<CrmContractProductDO> list) {
|
||||||
List<StoreProductAttrValueApiVO> storeProductAttrValueList = new ArrayList<>();
|
List<StoreProductAttrValueApiVO> storeProductAttrValueList = new ArrayList<>();
|
||||||
if (CollUtil.isNotEmpty(list)) {
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
|
@ -95,7 +95,11 @@ public class CrmIndexServiceImpl implements CrmIndexService {
|
|||||||
if (RelationEnum.MY.getValue().equals(relation)) {
|
if (RelationEnum.MY.getValue().equals(relation)) {
|
||||||
ids.add(adminId);
|
ids.add(adminId);
|
||||||
} else if (RelationEnum.SUB.getValue().equals(relation)) {
|
} 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<CrmBusinessDO>()
|
Long count01 = businessMapper.selectCount(new LambdaQueryWrapper<CrmBusinessDO>()
|
||||||
|
@ -81,4 +81,37 @@
|
|||||||
money DESC
|
money DESC
|
||||||
LIMIT 10
|
LIMIT 10
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getProductCount"
|
||||||
|
resultType="cn.iocoder.yudao.module.product.api.storeproductattrvalue.vo.UserProductCountVO">
|
||||||
|
select
|
||||||
|
a.owner_user_id as userId,
|
||||||
|
b.nums AS nums,
|
||||||
|
b.product_id as productId,
|
||||||
|
b.name as name,
|
||||||
|
b.product_attr_unique as productAttrUnique,
|
||||||
|
b.price as price,
|
||||||
|
b.discount as discount,
|
||||||
|
b.subtotal as subtotal,
|
||||||
|
b.remarks as remarks
|
||||||
|
from crm_contract as a
|
||||||
|
left join crm_contract_product as b on a.id = b.contract_id
|
||||||
|
<where>
|
||||||
|
a.deleted = 0
|
||||||
|
and b.deleted = 0
|
||||||
|
<if test="userIds != null and userIds.length > 0">
|
||||||
|
AND a.owner_user_id in
|
||||||
|
<foreach collection="userIds" item="id" index="index" open="(" close=")" separator=",">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null and createTime.length > 0">
|
||||||
|
<if test="createTime[0] != null">
|
||||||
|
and a.create_time >= #{createTime[0]}
|
||||||
|
</if>
|
||||||
|
<if test="createTime[1] != null">
|
||||||
|
and a.create_time <= #{createTime[1]}
|
||||||
|
</if>
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -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;
|
||||||
|
}
|
@ -434,6 +434,7 @@ public class HolidayUserRecordServiceImpl implements HolidayUserRecordService {
|
|||||||
LocalDateTime now, String remark, Integer direction, String reason, Boolean recordZero) {
|
LocalDateTime now, String remark, Integer direction, String reason, Boolean recordZero) {
|
||||||
BigDecimal quota = userQuotaMap.get(userId);
|
BigDecimal quota = userQuotaMap.get(userId);
|
||||||
// -- 如果是0的话就不记录了 -- 如果不记录0 并且是0 直接return
|
// -- 如果是0的话就不记录了 -- 如果不记录0 并且是0 直接return
|
||||||
|
log.info("假期额度分配数量quota为:{},recordZero为:{}", quota, recordZero);
|
||||||
if (quota == null || (BigDecimal.ZERO.compareTo(quota) == 0 && !recordZero)) {
|
if (quota == null || (BigDecimal.ZERO.compareTo(quota) == 0 && !recordZero)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user