CRM:增加合同配置表

This commit is contained in:
YunaiV 2024-02-24 16:51:16 +08:00
parent 616ae8eaeb
commit 0b0830f445
18 changed files with 255 additions and 27 deletions

View File

@ -96,6 +96,12 @@ public interface LogRecordConstants {
String CRM_BUSINESS_UPDATE_STATUS_SUB_TYPE = "更新商机状态"; String CRM_BUSINESS_UPDATE_STATUS_SUB_TYPE = "更新商机状态";
String CRM_BUSINESS_UPDATE_STATUS_SUCCESS = "更新了商机【{{#businessName}}】的状态从【{{#oldStatusName}}】变更为了【{{#newStatusName}}】"; String CRM_BUSINESS_UPDATE_STATUS_SUCCESS = "更新了商机【{{#businessName}}】的状态从【{{#oldStatusName}}】变更为了【{{#newStatusName}}】";
// ======================= CRM_CONTRACT_CONFIG 合同配置 =======================
String CRM_CONTRACT_CONFIG_TYPE = "CRM 合同配置";
String CRM_CONTRACT_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新合同配置' : '创建合同配置'}}";
String CRM_CONTRACT_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了合同配置' : '创建了合同配置'}}";
// ======================= CRM_CONTRACT 合同 ======================= // ======================= CRM_CONTRACT 合同 =======================
String CRM_CONTRACT_TYPE = "CRM 合同"; String CRM_CONTRACT_TYPE = "CRM 合同";

View File

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - CRM 合同配置")
@RestController
@RequestMapping("/crm/contract-config")
@Validated
public class CrmContractConfigController {
@Resource
private CrmContractConfigService contractConfigService;
@GetMapping("/get")
@Operation(summary = "获取合同配置")
@PreAuthorize("@ss.hasPermission('crm:contract-config:query')")
public CommonResult<CrmContractConfigRespVO> getCustomerPoolConfig() {
CrmContractConfigDO config = contractConfigService.getContractConfig();
return success(BeanUtils.toBean(config, CrmContractConfigRespVO.class));
}
@PutMapping("/save")
@Operation(summary = "更新合同配置")
@PreAuthorize("@ss.hasPermission('crm:contract-config:update')")
public CommonResult<Boolean> saveCustomerPoolConfig(@Valid @RequestBody CrmContractConfigSaveReqVO updateReqVO) {
contractConfigService.saveContractConfig(updateReqVO);
return success(true);
}
}

View File

@ -9,10 +9,10 @@ import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractRespVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - CRM 合同配置 Response VO")
@Data
public class CrmContractConfigRespVO {
@Schema(description = "是否开启提前提醒", example = "true")
private Boolean notifyEnabled;
@Schema(description = "提前提醒天数", example = "2")
private Integer notifyDays;
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config;
import cn.hutool.core.util.BooleanUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import lombok.Data;
import java.util.Objects;
@Schema(description = "管理后台 - CRM 合同配置 Request VO")
@Data
public class CrmContractConfigSaveReqVO {
@Schema(description = "是否开启提前提醒", example = "true")
@DiffLogField(name = "是否开启提前提醒")
private Boolean notifyEnabled;
@Schema(description = "提前提醒天数", example = "2")
@DiffLogField(name = "提前提醒天数")
private Integer notifyDays;
@AssertTrue(message = "提前提醒天数不能为空")
@JsonIgnore
public boolean isNotifyDaysValid() {
if (!BooleanUtil.isTrue(getNotifyEnabled())) {
return true;
}
return Objects.nonNull(getNotifyDays());
}
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.framework.common.validation.InEnum;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmBusinessParseFunction; import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmBusinessParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmContactParseFunction; import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmContactParseFunction;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract;
import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;

View File

@ -20,6 +20,7 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
// TODO @芋艿要干掉
/** /**
* Crm 数据权限 Convert * Crm 数据权限 Convert
* *

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.contract;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.*;
import lombok.*;
@TableName("crm_contract_config")
@KeySequence("crm_contract_config_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CrmContractConfigDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 是否开启提前提醒
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private Boolean notifyEnabled;
/**
* 提前提醒天数
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private Integer notifyDays;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.crm.dal.mysql.contract;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 合同配置 Mapper
*
* @author Wanwan
*/
@Mapper
public interface CrmContractConfigMapper extends BaseMapperX<CrmContractConfigDO> {
default CrmContractConfigDO selectOne() {
return selectOne(new QueryWrapperX<CrmContractConfigDO>().limitN(1));
}
}

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.crm.service.contract;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO;
import jakarta.validation.Valid;
/**
* 合同配置 Service 接口
*
* @author 芋道源码
*/
public interface CrmContractConfigService {
/**
* 获得合同配置
*
* @return 合同配置
*/
CrmContractConfigDO getContractConfig();
/**
* 保存合同配置
*
* @param saveReqVO 更新信息
*/
void saveContractConfig(@Valid CrmContractConfigSaveReqVO saveReqVO);
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.crm.service.contract;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.config.CrmContractConfigSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractConfigDO;
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractConfigMapper;
import com.mzt.logapi.context.LogRecordContext;
import com.mzt.logapi.starter.annotation.LogRecord;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.Objects;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
/**
* 合同配置 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class CrmContractConfigServiceImpl implements CrmContractConfigService {
@Resource
private CrmContractConfigMapper contractConfigMapper;
@Override
public CrmContractConfigDO getContractConfig() {
return contractConfigMapper.selectOne();
}
@Override
@LogRecord(type = CRM_CONTRACT_CONFIG_TYPE, subType = CRM_CONTRACT_CONFIG_SUB_TYPE, bizNo = "{{#configId}}",
success = CRM_CONTRACT_CONFIG_SUCCESS)
public void saveContractConfig(CrmContractConfigSaveReqVO saveReqVO) {
// 1. 存在则进行更新
CrmContractConfigDO dbConfig = getContractConfig();
CrmContractConfigDO config = BeanUtils.toBean(saveReqVO, CrmContractConfigDO.class);
if (Objects.nonNull(dbConfig)) {
contractConfigMapper.updateById(config.setId(dbConfig.getId()));
// 记录操作日志上下文
LogRecordContext.putVariable("isConfigUpdate", Boolean.TRUE);
LogRecordContext.putVariable("configId", config.getId());
return;
}
// 2. 不存在则进行插入
contractConfigMapper.insert(config);
// 记录操作日志上下文
LogRecordContext.putVariable("isConfigUpdate", Boolean.FALSE);
LogRecordContext.putVariable("configId", config.getId());
}
}

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.crm.service.contract; package cn.iocoder.yudao.module.crm.service.contract;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO;

View File

@ -10,9 +10,9 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO;
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;

View File

@ -26,26 +26,16 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe
@Resource @Resource
private CrmCustomerPoolConfigMapper customerPoolConfigMapper; private CrmCustomerPoolConfigMapper customerPoolConfigMapper;
/**
* 获得客户公海配置
*
* @return 客户公海配置
*/
@Override @Override
public CrmCustomerPoolConfigDO getCustomerPoolConfig() { public CrmCustomerPoolConfigDO getCustomerPoolConfig() {
return customerPoolConfigMapper.selectOne(); return customerPoolConfigMapper.selectOne();
} }
/**
* 保存客户公海配置
*
* @param saveReqVO 更新信息
*/
@Override @Override
@LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}",
success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS)
public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) {
// 存在则进行更新 // 1. 存在则进行更新
CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig();
CrmCustomerPoolConfigDO poolConfig = BeanUtils.toBean(saveReqVO, CrmCustomerPoolConfigDO.class); CrmCustomerPoolConfigDO poolConfig = BeanUtils.toBean(saveReqVO, CrmCustomerPoolConfigDO.class);
if (Objects.nonNull(dbConfig)) { if (Objects.nonNull(dbConfig)) {
@ -55,7 +45,8 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe
LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); LogRecordContext.putVariable("poolConfigId", poolConfig.getId());
return; return;
} }
// 不存在则进行插入
// 2. 不存在则进行插入
customerPoolConfigMapper.insert(poolConfig); customerPoolConfigMapper.insert(poolConfig);
// 记录操作日志上下文 // 记录操作日志上下文
LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.FALSE); LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.FALSE);