mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	Merge branch 'develop' of https://gitee.com/puhui999/ruoyi-vue-pro into develop
# Conflicts: # yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java # yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
This commit is contained in:
		| @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.map.MapUtil; | ||||
| import cn.iocoder.yudao.framework.common.core.KeyValue; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| @@ -10,9 +9,7 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.framework.excel.core.enums.ExcelColumn; | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
| import cn.iocoder.yudao.framework.ip.core.Area; | ||||
| import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; | ||||
| @@ -38,7 +35,6 @@ import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| @@ -49,7 +45,6 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | ||||
| import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||||
| import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||||
| import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.*; | ||||
| import static java.util.Collections.singletonList; | ||||
|  | ||||
| @Tag(name = "管理后台 - CRM 客户") | ||||
| @@ -265,25 +260,7 @@ public class CrmCustomerController { | ||||
|                         .areaId(null).detailAddress("").remark("").build() | ||||
|         ); | ||||
|         // 输出 | ||||
|         ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list, builderSelectMap()); | ||||
|     } | ||||
|  | ||||
|     private List<KeyValue<ExcelColumn, List<String>>> builderSelectMap() { | ||||
|         List<KeyValue<ExcelColumn, List<String>>> selectMap = new ArrayList<>(); | ||||
|         // 获取地区下拉数据 | ||||
|         // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? | ||||
|         Area area = AreaUtils.getArea(Area.ID_CHINA); | ||||
|         selectMap.add(new KeyValue<>(ExcelColumn.G, AreaUtils.getAreaNodePathList(area.getChildren()))); | ||||
|         // 获取客户所属行业 | ||||
|         List<String> customerIndustries = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY); | ||||
|         selectMap.add(new KeyValue<>(ExcelColumn.I, customerIndustries)); | ||||
|         // 获取客户等级 | ||||
|         List<String> customerLevels = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL); | ||||
|         selectMap.add(new KeyValue<>(ExcelColumn.J, customerLevels)); | ||||
|         // 获取客户来源 | ||||
|         List<String> customerSources = dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE); | ||||
|         selectMap.add(new KeyValue<>(ExcelColumn.K, customerSources)); | ||||
|         return selectMap; | ||||
|         ExcelUtils.write(response, "客户导入模板.xls", "客户列表", CrmCustomerImportExcelVO.class, list); | ||||
|     } | ||||
|  | ||||
|     @PostMapping("/import") | ||||
|   | ||||
| @@ -1,8 +1,13 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||||
| import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; | ||||
| import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert; | ||||
| import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||||
| import cn.iocoder.yudao.module.crm.framework.excel.service.AreaExcelColumnSelectDataServiceImpl; | ||||
| import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerIndustryExcelColumnSelectDataServiceImpl; | ||||
| import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerLevelExcelColumnSelectDataServiceImpl; | ||||
| import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerSourceExcelColumnSelectDataServiceImpl; | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Builder; | ||||
| @@ -41,6 +46,7 @@ public class CrmCustomerImportExcelVO { | ||||
|     private String email; | ||||
|  | ||||
|     @ExcelProperty(value = "地区", converter = AreaConvert.class) | ||||
|     @ExcelColumnSelect(AreaExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | ||||
|     private Integer areaId; | ||||
|  | ||||
|     @ExcelProperty("详细地址") | ||||
| @@ -48,14 +54,17 @@ public class CrmCustomerImportExcelVO { | ||||
|  | ||||
|     @ExcelProperty(value = "所属行业", converter = DictConvert.class) | ||||
|     @DictFormat(CRM_CUSTOMER_INDUSTRY) | ||||
|     @ExcelColumnSelect(CrmCustomerIndustryExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | ||||
|     private Integer industryId; | ||||
|  | ||||
|     @ExcelProperty(value = "客户等级", converter = DictConvert.class) | ||||
|     @DictFormat(CRM_CUSTOMER_LEVEL) | ||||
|     @ExcelColumnSelect(CrmCustomerLevelExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | ||||
|     private Integer level; | ||||
|  | ||||
|     @ExcelProperty(value = "客户来源", converter = DictConvert.class) | ||||
|     @DictFormat(CRM_CUSTOMER_SOURCE) | ||||
|     @ExcelColumnSelect(CrmCustomerSourceExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | ||||
|     private Integer source; | ||||
|  | ||||
|     @ExcelProperty("备注") | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; | ||||
|  | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; | ||||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| @@ -8,53 +9,69 @@ import lombok.Data; | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| // TODO @puhui999:缺导出 | ||||
| @Schema(description = "管理后台 - CRM 回款计划 Response VO") | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| public class CrmReceivablePlanRespVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||||
|     @ExcelProperty("编号") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "期数", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||||
|     @ExcelProperty("期数") | ||||
|     private Integer period; | ||||
|  | ||||
|     @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||||
|     @ExcelProperty("客户编号") | ||||
|     private Long customerId; | ||||
|     @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") | ||||
|     @ExcelProperty("客户名字") | ||||
|     private String customerName; | ||||
|  | ||||
|     @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||||
|     @ExcelProperty("合同编号") | ||||
|     private Long contractId; | ||||
|     @Schema(description = "合同编号", example = "Q110") | ||||
|     @ExcelProperty("合同编号") | ||||
|     private String contractNo; | ||||
|  | ||||
|     @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||||
|     @ExcelProperty("负责人编号") | ||||
|     private Long ownerUserId; | ||||
|     @Schema(description = "负责人", example = "test") | ||||
|     @ExcelProperty("负责人") | ||||
|     private String ownerUserName; | ||||
|  | ||||
|     @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") | ||||
|     @ExcelProperty("计划回款日期") | ||||
|     private LocalDateTime returnTime; | ||||
|  | ||||
|     @Schema(description = "计划回款方式", example = "1") | ||||
|     @ExcelProperty("计划回款方式") | ||||
|     private Integer returnType; | ||||
|  | ||||
|     @Schema(description = "计划回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") | ||||
|     @ExcelProperty("计划回款金额") | ||||
|     private BigDecimal price; | ||||
|  | ||||
|     @Schema(description = "回款编号", example = "19852") | ||||
|     @ExcelProperty("回款编号") | ||||
|     private Long receivableId; | ||||
|     @Schema(description = "回款信息") | ||||
|     @ExcelProperty("回款信息") | ||||
|     private CrmReceivableRespVO receivable; | ||||
|  | ||||
|     @Schema(description = "提前几天提醒", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||||
|     @ExcelProperty("提前几天提醒") | ||||
|     private Integer remindDays; | ||||
|  | ||||
|     @Schema(description = "提醒日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") | ||||
|     @ExcelProperty("提醒日期") | ||||
|     private LocalDateTime remindTime; | ||||
|  | ||||
|     @Schema(description = "备注", example = "备注") | ||||
|     @ExcelProperty("备注") | ||||
|     private String remark; | ||||
|  | ||||
|     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; | ||||
|  | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractRespVO; | ||||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| @@ -8,37 +9,47 @@ import lombok.Data; | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| // TODO 芋艿:导出的 VO,可以考虑使用 @Excel 注解,实现导出功能 | ||||
| @Schema(description = "管理后台 - CRM 回款 Response VO") | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| public class CrmReceivableRespVO { | ||||
|  | ||||
|     @Schema(description = "编号", example = "25787") | ||||
|     @ExcelProperty("编号") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "回款编号", example = "31177") | ||||
|     @ExcelProperty("回款编号") | ||||
|     private String no; | ||||
|  | ||||
|     @Schema(description = "回款计划编号", example = "1024") | ||||
|     @ExcelProperty("回款计划编号") | ||||
|     private Long planId; | ||||
|  | ||||
|     @Schema(description = "回款方式", example = "2") | ||||
|     @ExcelProperty("回款方式") | ||||
|     private Integer returnType; | ||||
|  | ||||
|     @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "9000") | ||||
|     @ExcelProperty("回款金额") | ||||
|     private BigDecimal price; | ||||
|  | ||||
|     @Schema(description = "计划回款日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02") | ||||
|     @ExcelProperty("计划回款日期") | ||||
|     private LocalDateTime returnTime; | ||||
|  | ||||
|     @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||||
|     @ExcelProperty("客户编号") | ||||
|     private Long customerId; | ||||
|     @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") | ||||
|     @ExcelProperty("客户名字") | ||||
|     private String customerName; | ||||
|  | ||||
|     @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||||
|     @ExcelProperty("合同编号") | ||||
|     private Long contractId; | ||||
|     @Schema(description = "合同信息") | ||||
|     @ExcelProperty("合同信息") | ||||
|     private CrmContractRespVO contract; | ||||
|  | ||||
|     @Schema(description = "负责人的用户编号", example = "25682") | ||||
| @@ -56,20 +67,26 @@ public class CrmReceivableRespVO { | ||||
|     private String processInstanceId; | ||||
|  | ||||
|     @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||||
|     @ExcelProperty("审批状态") | ||||
|     private Integer auditStatus; | ||||
|  | ||||
|     @Schema(description = "备注", example = "备注") | ||||
|     @Schema(description = "工作流编号", example = "备注") | ||||
|     @ExcelProperty("工作流编号") | ||||
|     private String remark; | ||||
|  | ||||
|     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
|     @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||||
|     @ExcelProperty("更新时间") | ||||
|     private LocalDateTime updateTime; | ||||
|  | ||||
|     @Schema(description = "创建人", example = "25682") | ||||
|     @ExcelProperty("创建人") | ||||
|     private String creator; | ||||
|     @Schema(description = "创建人名字", example = "test") | ||||
|     @ExcelProperty("创建人名字") | ||||
|     private String creatorName; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1 @@ | ||||
| package cn.iocoder.yudao.module.crm.framework.excel; | ||||
| @@ -0,0 +1,38 @@ | ||||
| package cn.iocoder.yudao.module.crm.framework.excel.service; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||||
| import cn.iocoder.yudao.framework.ip.core.Area; | ||||
| import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | ||||
| import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * Excel 所属地区列下拉数据源获取接口实现类 | ||||
|  * | ||||
|  * @author HUIHUI | ||||
|  */ | ||||
| @Service | ||||
| public class AreaExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | ||||
|  | ||||
|     public static final String FUNCTION_NAME = "getCrmAreaNameList"; // 防止和别的模块重名 | ||||
|  | ||||
|     @Resource | ||||
|     private DictDataApi dictDataApi; | ||||
|  | ||||
|     @Override | ||||
|     public String getFunctionName() { | ||||
|         return FUNCTION_NAME; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<String> getSelectDataList() { | ||||
|         // 获取地区下拉数据 | ||||
|         // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? | ||||
|         Area area = AreaUtils.parseArea(Area.ID_CHINA); | ||||
|         return AreaUtils.getAreaNodePathList(area.getChildren()); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,35 @@ | ||||
| package cn.iocoder.yudao.module.crm.framework.excel.service; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||||
| import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; | ||||
|  | ||||
| /** | ||||
|  * Excel 客户所属行业列下拉数据源获取接口实现类 | ||||
|  * | ||||
|  * @author HUIHUI | ||||
|  */ | ||||
| @Service | ||||
| public class CrmCustomerIndustryExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | ||||
|  | ||||
|     public static final String FUNCTION_NAME = "getCrmCustomerIndustryList"; | ||||
|  | ||||
|     @Resource | ||||
|     private DictDataApi dictDataApi; | ||||
|  | ||||
|     @Override | ||||
|     public String getFunctionName() { | ||||
|         return FUNCTION_NAME; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<String> getSelectDataList() { | ||||
|         return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,35 @@ | ||||
| package cn.iocoder.yudao.module.crm.framework.excel.service; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||||
| import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL; | ||||
|  | ||||
| /** | ||||
|  * Excel 客户等级列下拉数据源获取接口实现类 | ||||
|  * | ||||
|  * @author HUIHUI | ||||
|  */ | ||||
| @Service | ||||
| public class CrmCustomerLevelExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | ||||
|  | ||||
|     public static final String FUNCTION_NAME = "getCrmCustomerLevelList"; | ||||
|  | ||||
|     @Resource | ||||
|     private DictDataApi dictDataApi; | ||||
|  | ||||
|     @Override | ||||
|     public String getFunctionName() { | ||||
|         return FUNCTION_NAME; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<String> getSelectDataList() { | ||||
|         return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,35 @@ | ||||
| package cn.iocoder.yudao.module.crm.framework.excel.service; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | ||||
| import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | ||||
| import jakarta.annotation.Resource; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE; | ||||
|  | ||||
| /** | ||||
|  * Excel 客户来源列下拉数据源获取接口实现类 | ||||
|  * | ||||
|  * @author HUIHUI | ||||
|  */ | ||||
| @Service | ||||
| public class CrmCustomerSourceExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | ||||
|  | ||||
|     public static final String FUNCTION_NAME = "getCrmCustomerSourceList"; | ||||
|  | ||||
|     @Resource | ||||
|     private DictDataApi dictDataApi; | ||||
|  | ||||
|     @Override | ||||
|     public String getFunctionName() { | ||||
|         return FUNCTION_NAME; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<String> getSelectDataList() { | ||||
|         return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -30,12 +30,14 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | ||||
| import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; | ||||
| import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; | ||||
| import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | ||||
| import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| import com.mzt.logapi.context.LogRecordContext; | ||||
| import com.mzt.logapi.service.impl.DiffParseFunction; | ||||
| import com.mzt.logapi.starter.annotation.LogRecord; | ||||
| import jakarta.annotation.Resource; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.context.annotation.Lazy; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| @@ -86,7 +88,9 @@ public class CrmContractServiceImpl implements CrmContractService { | ||||
|     private CrmContactService contactService; | ||||
|     @Resource | ||||
|     private CrmContractConfigService contractConfigService; | ||||
|  | ||||
|     @Resource | ||||
|     @Lazy // 延迟加载,避免循环依赖 | ||||
|     private CrmReceivableService receivableService; | ||||
|     @Resource | ||||
|     private AdminUserApi adminUserApi; | ||||
|     @Resource | ||||
| @@ -222,9 +226,12 @@ public class CrmContractServiceImpl implements CrmContractService { | ||||
|             success = CRM_CONTRACT_DELETE_SUCCESS) | ||||
|     @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) | ||||
|     public void deleteContract(Long id) { | ||||
|         // TODO @puhui999:如果被 CrmReceivableDO 所使用,则不允许删除 | ||||
|         // 校验存在 | ||||
|         CrmContractDO contract = validateContractExists(id); | ||||
|         // 如果被 CrmReceivableDO 所使用,则不允许删除 | ||||
|         if (CollUtil.isNotEmpty(receivableService.getReceivableByContractId(contract.getId()))) { | ||||
|             throw exception(CONTRACT_DELETE_FAIL); | ||||
|         } | ||||
|         // 删除 | ||||
|         contractMapper.deleteById(id); | ||||
|         // 删除数据权限 | ||||
|   | ||||
| @@ -122,4 +122,12 @@ public interface CrmReceivableService { | ||||
|      */ | ||||
|     Map<Long, BigDecimal> getReceivablePriceMapByContractId(Collection<Long> contractIds); | ||||
|  | ||||
|     /** | ||||
|      * 更具合同编号查询回款列表 | ||||
|      * | ||||
|      * @param contractId 合同编号 | ||||
|      * @return 回款 | ||||
|      */ | ||||
|     List<CrmReceivableDO> getReceivableByContractId(Long contractId); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -37,10 +37,7 @@ import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.*; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | ||||
| @@ -81,7 +78,6 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|     @Resource | ||||
|     private BpmProcessInstanceApi bpmProcessInstanceApi; | ||||
|  | ||||
|     // TODO @puhui999:操作日志没记录上 | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_CREATE_SUB_TYPE, bizNo = "{{#receivable.id}}", | ||||
| @@ -115,6 +111,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|  | ||||
|         // 5. 记录操作日志上下文 | ||||
|         LogRecordContext.putVariable("receivable", receivable); | ||||
|         LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); | ||||
|         return receivable.getId(); | ||||
|     } | ||||
|  | ||||
| @@ -156,7 +153,6 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // TODO @puhui999:操作日志没记录上 | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     @LogRecord(type = CRM_RECEIVABLE_TYPE, subType = CRM_RECEIVABLE_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", | ||||
| @@ -164,11 +160,14 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|     @CrmPermission(bizType = CrmBizTypeEnum.CRM_RECEIVABLE, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) | ||||
|     public void updateReceivable(CrmReceivableSaveReqVO updateReqVO) { | ||||
|         Assert.notNull(updateReqVO.getId(), "回款编号不能为空"); | ||||
|         // 1.1 校验可回款金额超过上限 | ||||
|         validateReceivablePriceExceedsLimit(updateReqVO); | ||||
|         updateReqVO.setOwnerUserId(null).setCustomerId(null).setContractId(null).setPlanId(null); // 不允许修改的字段 | ||||
|         // 1.2 校验存在 | ||||
|         // 1.1 校验存在 | ||||
|         CrmReceivableDO receivable = validateReceivableExists(updateReqVO.getId()); | ||||
|         updateReqVO.setOwnerUserId(receivable.getOwnerUserId()).setCustomerId(receivable.getCustomerId()) | ||||
|                 .setContractId(receivable.getContractId()).setPlanId(receivable.getPlanId()); // 设置已存在的值 | ||||
|         // 1.2 校验可回款金额超过上限 | ||||
|         validateReceivablePriceExceedsLimit(updateReqVO); | ||||
|  | ||||
|         // 1.3 只有草稿、审批中,可以编辑; | ||||
|         if (!ObjectUtils.equalsAny(receivable.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(), | ||||
|                 CrmAuditStatusEnum.PROCESS.getStatus())) { | ||||
| @@ -180,8 +179,17 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|         receivableMapper.updateById(updateObj); | ||||
|  | ||||
|         // 3. 记录操作日志上下文 | ||||
|         LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class)); | ||||
|         LogRecordContext.putVariable("receivable", receivable); | ||||
|         LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); | ||||
|         LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(receivable, CrmReceivableSaveReqVO.class)); | ||||
|     } | ||||
|  | ||||
|     private Integer getReceivablePeriod(Long planId) { | ||||
|         if (Objects.isNull(planId)) { | ||||
|             return null; | ||||
|         } | ||||
|         CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(planId); | ||||
|         return receivablePlan.getPeriod(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -212,8 +220,10 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|         if (receivable.getPlanId() != null && receivablePlanService.getReceivablePlan(receivable.getPlanId()) != null) { | ||||
|             throw exception(RECEIVABLE_DELETE_FAIL); | ||||
|         } | ||||
|         // TODO @puhui999:审批通过时,不允许删除; | ||||
|  | ||||
|         // 1.3 审批通过时,不允许删除 | ||||
|         if (ObjUtil.equal(receivable.getAuditStatus(), CrmAuditStatusEnum.APPROVE.getStatus())) { | ||||
|             throw exception(RECEIVABLE_DELETE_FAIL_IS_APPROVE); | ||||
|         } | ||||
|         // 2. 删除 | ||||
|         receivableMapper.deleteById(id); | ||||
|         // 3. 删除数据权限 | ||||
| @@ -221,6 +231,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|  | ||||
|         // 4. 记录操作日志上下文 | ||||
|         LogRecordContext.putVariable("receivable", receivable); | ||||
|         LogRecordContext.putVariable("period", getReceivablePeriod(receivable.getPlanId())); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @@ -289,4 +300,9 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | ||||
|         return receivableMapper.selectReceivablePriceMapByContractId(contractIds); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<CrmReceivableDO> getReceivableByContractId(Long contractId) { | ||||
|         return receivableMapper.selectList(CrmReceivableDO::getContractId, contractId); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV