Commit aacd13201d5da4f0e848cb74e280f78d1e2a1c85

Authored by yeqianyong
2 parents ed5604fb d9dd5e2a

Merge remote-tracking branch 'origin/master_0929' into master_0929

Showing 25 changed files with 632 additions and 14 deletions
... ... @@ -9,6 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
9 9 import org.springframework.boot.web.servlet.ServletComponentScan;
10 10 import org.springframework.context.annotation.Bean;
11 11 import org.springframework.context.annotation.Configuration;
  12 +import org.springframework.scheduling.annotation.EnableScheduling;
12 13 import springfox.documentation.builders.ApiInfoBuilder;
13 14 import springfox.documentation.builders.PathSelectors;
14 15 import springfox.documentation.builders.RequestHandlerSelectors;
... ... @@ -19,6 +20,7 @@ import springfox.documentation.spring.web.plugins.Docket;
19 20 @EnableLock(type = LockType.REDIS)
20 21 @ServletComponentScan(basePackages = {"com.lframework.xingyun"})
21 22 @SpringBootApplication(scanBasePackages = {"com.lframework.xingyun"})
  23 +@EnableScheduling
22 24 @MapperScan({"com.lframework.xingyun.**.mappers"})
23 25 public class XingYunApiApplication {
24 26
... ...
... ... @@ -3,9 +3,9 @@ server:
3 3 port: 8081
4 4 spring:
5 5 application:
6   - name: @project.artifactId@
  6 + name: "@project.artifactId@"
7 7 profiles:
8   - active: @profiles-active@
  8 + active: "@profiles-active@"
9 9 servlet:
10 10 multipart:
11 11 #是否开启文件上传
... ...
... ... @@ -106,6 +106,12 @@ public class QuerySpecLockDelayApplicationBo extends BaseBo<SpecLockDelayApplica
106 106 @ApiModelProperty(value = "数量(t)")
107 107 private BigDecimal totalQuantity;
108 108
  109 + /**
  110 + * 是否展示审核按钮(非持久化字段)
  111 + */
  112 + @ApiModelProperty(value = "是否展示审核按钮")
  113 + private Boolean showExamine;
  114 +
109 115 public QuerySpecLockDelayApplicationBo() {
110 116
111 117 }
... ...
... ... @@ -444,6 +444,19 @@ public class GetCustomerCreditBo extends BaseBo<CustomerCredit> implements BaseD
444 444 @ApiModelProperty(value = "是否展示审核按钮")
445 445 private Boolean showExamine;
446 446
  447 +
  448 + /**
  449 + * 企业操作类型
  450 + */
  451 + @ApiModelProperty("企业操作类型")
  452 + private String enterpriseOperationType;
  453 +
  454 + /**
  455 + * 冻结状态(正常:NORMAL,冻结:FROZEN)
  456 + */
  457 + @ApiModelProperty(value = "冻结状态")
  458 + private String frozenStatus;
  459 +
447 460 /**
448 461 * 核心人员
449 462 */
... ...
... ... @@ -250,4 +250,18 @@ public class SpecLockDelayApplicationController extends DefaultBaseController {
250 250 return InvokeResultBuilder.success(result);
251 251 }
252 252
  253 +
  254 + /**
  255 + * 订单申请延期取消
  256 + */
  257 + @ApiOperation("订单申请延期取消")
  258 + @GetMapping("/cancel")
  259 + public InvokeResult<Void> cancel(@NotBlank(message = "id不能为空!") String id) {
  260 +
  261 + specLockDelayApplicationService.cancelApplication(id);
  262 +
  263 + specLockDelayApplicationService.cleanCacheByKey(id);
  264 +
  265 + return InvokeResultBuilder.success();
  266 + }
253 267 }
... ...
... ... @@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
21 21 import javax.validation.constraints.NotBlank;
22 22 import com.lframework.xingyun.sc.excel.customerCredit.CustomerCreditImportListener;
23 23 import com.lframework.xingyun.sc.excel.customerCredit.CustomerCreditImportModel;
  24 +import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
24 25 import com.lframework.xingyun.sc.service.customer.CorePersonnelService;
25 26 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
26 27 import com.lframework.xingyun.sc.vo.customer.credit.CreateCustomerCreditVo;
... ... @@ -35,6 +36,7 @@ import com.lframework.starter.common.utils.CollectionUtil;
35 36 import io.swagger.annotations.Api;
36 37 import org.springframework.beans.factory.annotation.Autowired;
37 38 import org.springframework.beans.factory.annotation.Value;
  39 +import org.springframework.scheduling.annotation.Scheduled;
38 40 import org.springframework.validation.annotation.Validated;
39 41 import org.springframework.web.bind.annotation.*;
40 42 import org.springframework.web.multipart.MultipartFile;
... ... @@ -43,7 +45,10 @@ import javax.validation.Valid;
43 45 import javax.validation.constraints.NotNull;
44 46 import java.io.*;
45 47 import java.net.URLEncoder;
46   -import java.util.List;
  48 +import java.time.LocalDate;
  49 +import java.time.LocalDateTime;
  50 +import java.time.format.DateTimeFormatter;
  51 +import java.util.*;
47 52 import java.util.stream.Collectors;
48 53
49 54 /**
... ... @@ -68,6 +73,8 @@ public class CustomerCreditController extends DefaultBaseController {
68 73 private RedisHandler redisHandler;
69 74 @Value("${customer.credit.export:/web/service/erp/xingyun/export/templates/}")
70 75 private String exportTemplate;
  76 + @Resource
  77 + private ContractDistributorStandardService contractDistributorStandardService;
71 78
72 79 /**
73 80 * 查询列表
... ... @@ -83,7 +90,32 @@ public class CustomerCreditController extends DefaultBaseController {
83 90 List<GetCustomerCreditBo> results = null;
84 91
85 92 if (!CollectionUtil.isEmpty(datas)) {
86   - results = datas.stream().map(GetCustomerCreditBo::new).collect(Collectors.toList());
  93 + results = datas.stream().map(data -> {
  94 + GetCustomerCreditBo bo = new GetCustomerCreditBo(data);
  95 + // frozenStatus 转中文
  96 + String frozenStatus = data.getFrozenStatus();
  97 + if ("NORMAL".equals(frozenStatus)) {
  98 + bo.setFrozenStatus("正常");
  99 + } else if ("FROZEN".equals(frozenStatus)) {
  100 + bo.setFrozenStatus("冻结");
  101 + } else {
  102 + bo.setFrozenStatus("");
  103 + }
  104 +
  105 + // enterpriseOperationType 转中文
  106 + String opType = data.getEnterpriseOperationType();
  107 + if ("NEW_CUSTOMER".equals(opType)) {
  108 + bo.setEnterpriseOperationType("新开发客户");
  109 + } else if ("RECONNECT_CUSTOMER".equals(opType)) {
  110 + bo.setEnterpriseOperationType("再接轨客户");
  111 + } else if ("OLD_CUSTOMER".equals(opType)) {
  112 + bo.setEnterpriseOperationType("老客户");
  113 + } else {
  114 + bo.setEnterpriseOperationType("");
  115 + }
  116 +
  117 + return bo;
  118 + }).collect(Collectors.toList());
87 119 }
88 120
89 121 return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results));
... ... @@ -308,6 +340,86 @@ public class CustomerCreditController extends DefaultBaseController {
308 340 }
309 341 }
310 342
  343 + /**
  344 + * 定时任务:冻结
  345 + */
  346 + @Scheduled(cron = "0 0 0 31 3 ?")
  347 + @GetMapping("/frozenCustomerCredit")
  348 + public void frozenCustomerCredit() {
  349 + System.out.println("===定时任务开始===");
  350 + // 每年的3月31号去看今年1月1号之前建的资信,如果没在今年1月1号到3月31号之间申请变更并通过都给冻结
  351 + QueryCustomerCreditVo vo = new QueryCustomerCreditVo();
  352 + vo.setStatus("PASS");
  353 + vo.setFrozenStatus("NORMAL");
  354 + // 获取当前年份
  355 + int currentYear = LocalDate.now().getYear();
  356 + // 创建当年1月1日 00:00:00(本地时间)
  357 + LocalDateTime startOfYear = LocalDateTime.of(currentYear, 1, 1, 0, 0, 0);
  358 + // 定义格式
  359 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
  360 + // 转为字符串
  361 + String formattedDate = startOfYear.format(formatter);
  362 + vo.setCreateTimeStr(formattedDate);
  363 + //创建时间
  364 + List<CustomerCredit> creditList = customerCreditService.query(vo);
  365 + if (CollectionUtil.isNotEmpty(creditList)) {
  366 + List<String> idList = creditList.stream()
  367 + .map(CustomerCredit::getId)
  368 + .collect(Collectors.toList());
  369 + List<String> needFrozenIds = customerCreditService.getNeedFrozenIds(idList, formattedDate);
  370 + //冻结客户资信
  371 + customerCreditService.updateFrozenStatus(needFrozenIds, "FROZEN");
  372 + }
  373 + System.out.println("===定时任务结束===");
  374 + }
  375 +
  376 + /**
  377 + * 定时任务:更新企业操作类型
  378 + */
  379 + @Scheduled(cron = "0 0 1 * * ?")
  380 + @GetMapping("/updateEnterpriseOperationType")
  381 + public void updateEnterpriseOperationType() {
  382 + System.out.println("===定时任务开始===");
  383 + //更新企业操作类型:新开发客户(在系统中未签订过合同的客户)、再接轨客户(在一年之前有签订过合同)、老客户(一年内有签订过合同)
  384 + List<CustomerCredit> customerCreditList = customerCreditService.query(new QueryCustomerCreditVo());
  385 + if (CollectionUtil.isNotEmpty(customerCreditList)) {
  386 + Map<String, String> map = new HashMap<>();
  387 + for (CustomerCredit customerCredit : customerCreditList) {
  388 + map.put(customerCredit.getCompanyId(), customerCredit.getId());
  389 + }
  390 + //客户合集
  391 + Set<String> companyIds = map.keySet();
  392 + ArrayList<String> companyIdList = new ArrayList<>(companyIds);
  393 + //一年之内未签订合同的客户集合
  394 + List<String> noContractSignedCompanyIds = contractDistributorStandardService.getNoContractSigned(companyIdList);
  395 + //一年之内签订过合同的客户集合
  396 + List<String> contractSignedCompanyIds = contractDistributorStandardService.getContractSigned(companyIdList);
  397 + //移除后得到从未签订过合同的客户
  398 + companyIdList.removeAll(noContractSignedCompanyIds);
  399 + companyIdList.removeAll(contractSignedCompanyIds);
  400 + System.out.println("companyIdList===" + companyIdList);
  401 + //一年之内未签订合同的客户资信
  402 + List<String> noContractSignedCreditIds = noContractSignedCompanyIds.stream()
  403 + .map(map::get) // 根据 companyId 获取对应的 creditId
  404 + .filter(Objects::nonNull) // 可选:防止 map 中不存在该 key(逻辑上应该都存在)
  405 + .collect(Collectors.toList());
  406 + customerCreditService.updateEnterpriseOperationType(noContractSignedCreditIds,"RECONNECT_CUSTOMER");
  407 + //一年之内签订过合同的客户资信
  408 + List<String> contractSignedCreditIds = contractSignedCompanyIds.stream()
  409 + .map(map::get) // 根据 companyId 获取对应的 creditId
  410 + .filter(Objects::nonNull) // 可选:防止 map 中不存在该 key(逻辑上应该都存在)
  411 + .collect(Collectors.toList());
  412 + customerCreditService.updateEnterpriseOperationType(contractSignedCreditIds,"OLD_CUSTOMER");
  413 + //从未签订过合同的客户资信
  414 + List<String> creditIds = companyIdList.stream()
  415 + .map(map::get) // 根据 companyId 获取对应的 creditId
  416 + .filter(Objects::nonNull) // 可选:防止 map 中不存在该 key(逻辑上应该都存在)
  417 + .collect(Collectors.toList());
  418 + customerCreditService.updateEnterpriseOperationType(creditIds,"NEW_CUSTOMER");
  419 + }
  420 + System.out.println("===定时任务结束===");
  421 + }
  422 +
311 423
312 424
313 425 /**
... ...
... ... @@ -9,6 +9,7 @@ import java.time.LocalDateTime;
9 9 import com.baomidou.mybatisplus.annotation.FieldFill;
10 10 import com.lframework.starter.web.core.entity.BaseEntity;
11 11 import com.baomidou.mybatisplus.annotation.TableField;
  12 +import io.swagger.annotations.ApiModelProperty;
12 13 import lombok.Data;
13 14
14 15 /**
... ... @@ -332,6 +333,16 @@ public class CustomerCredit extends BaseEntity implements BaseDto {
332 333 private String marketingCenterSupervisor;
333 334
334 335 /**
  336 + * 企业操作类型
  337 + */
  338 + private String enterpriseOperationType;
  339 +
  340 + /**
  341 + * 冻结状态(正常:NORMAL,冻结:FROZEN)
  342 + */
  343 + private String frozenStatus;
  344 +
  345 + /**
335 346 * 是否展示审核按钮(非持久化字段)
336 347 */
337 348 @TableField(exist = false)
... ...
... ... @@ -100,4 +100,9 @@ public class SpecLockDelayApplication extends BaseEntity implements BaseDto {
100 100 @TableField(fill = FieldFill.INSERT_UPDATE)
101 101 private LocalDateTime updateTime;
102 102
  103 + /**
  104 + * 是否展示正式合同审核按钮(非持久化字段)
  105 + */
  106 + @TableField(exist = false)
  107 + private Boolean showExamine;
103 108 }
... ...
... ... @@ -41,4 +41,18 @@ public enum CustomerDevelopStatus implements BaseEnum<Integer> {
41 41 }
42 42 return null;
43 43 }
  44 +
  45 + /**
  46 + * 通过name获取desc(安全版本,不区分大小写)
  47 + * @param name 枚举名称
  48 + * @return 描述信息
  49 + */
  50 + public static String getDescByNameSafe(String name) {
  51 + for (CustomerDevelopStatus status : values()) {
  52 + if (status.name().equalsIgnoreCase(name)) {
  53 + return status.getDesc();
  54 + }
  55 + }
  56 + return null;
  57 + }
44 58 }
... ...
... ... @@ -11,6 +11,7 @@ import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
11 11 import com.lframework.xingyun.sc.entity.*;
12 12 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
13 13 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
  14 +import com.lframework.xingyun.sc.service.contract.SpecLockDelayApplicationService;
14 15 import com.lframework.xingyun.sc.service.customer.CorePersonnelHistoryService;
15 16 import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService;
16 17 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
... ... @@ -66,6 +67,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
66 67 private MqProducerService mqProducerService;
67 68 @Resource
68 69 private TransactorHandler transactorHandler;
  70 + @Resource
  71 + private SpecLockDelayApplicationService specLockDelayApplicationService;
69 72
70 73
71 74 /**
... ... @@ -118,6 +121,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
118 121 case "SPEC_CHANGE_CONFIRM":
119 122 handleOrderSpecChangeData(flowStatus, businessId);
120 123 break;
  124 + case "SPEC_LOCK_DELAY":
  125 + handleSpecLockDelayAuditData(flowStatus, businessId);
  126 + break;
121 127 default:
122 128 break;
123 129 }
... ... @@ -150,6 +156,19 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
150 156 }
151 157 }
152 158
  159 + private void handleSpecLockDelayAuditData(String flowStatus, String businessId) {
  160 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  161 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
  162 + specLockDelayApplicationService.updateAuditStatus(businessId, "PASS");
  163 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  164 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
  165 + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
  166 + specLockDelayApplicationService.updateAuditStatus(businessId, "REFUSE");
  167 + } else if (FlowInstanceStatus.UNDO.getCode().equals(flowStatus)) {
  168 + specLockDelayApplicationService.updateAuditStatus(businessId, "REFUSE");
  169 + }
  170 + }
  171 +
153 172 /**
154 173 * 客户开发业务数据处理
155 174 *
... ... @@ -305,6 +324,10 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
305 324 customerCreditService.updateNoFlowInstance(vo);
306 325 //清除缓存
307 326 redisHandler.del(businessId);
  327 + //更新冻结状态为正常
  328 + List<String> list = new ArrayList<>();
  329 + list.add(businessId);
  330 + customerCreditService.updateFrozenStatus(list, "NORMAL");
308 331 } else {
309 332 //非变更审核
310 333 customerCreditService.updateStatus(businessId, "PASS");
... ... @@ -347,8 +370,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
347 370 /**
348 371 * 处理订货单变更相关数据
349 372 *
350   - * @param flowStatus 审核结果
351   - * @param businessId 业务ID
  373 + * @param flowStatus 审核结果
  374 + * @param businessId 业务ID
352 375 */
353 376 private void handleOrderSpecChangeData(String flowStatus, String businessId) {
354 377 if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
... ...
... ... @@ -38,6 +38,7 @@ import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractDistributorS
38 38 import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractStdProcessingLineVo;
39 39 import org.apache.commons.collections4.CollectionUtils;
40 40 import org.apache.commons.lang3.StringUtils;
  41 +import org.apache.ibatis.annotations.Param;
41 42 import org.springframework.beans.factory.annotation.Autowired;
42 43 import org.springframework.cache.annotation.CacheEvict;
43 44 import org.springframework.cache.annotation.Cacheable;
... ... @@ -496,7 +497,9 @@ public class ContractDistributorStandardServiceImpl extends
496 497 .set(ContractDistributorStandard::getStandardStandardized, vo.getStandardStandardized())
497 498 .set(ContractDistributorStandard::getStandardApproved, CustomerDevelopStatus.AUDIT.name());
498 499 if (!data.getStatus().equals("STANDARD")
499   - && ("DISTRIB_STD".equals(data.getType()) || "INTL_STD_CONTRACT".equals(data.getType()))) { // 只有经销(外贸)标准合同才修改状态
  500 + && ("DISTRIB_STD".equals(data.getType())
  501 + || "INTL_STD_CONTRACT".equals(data.getType())
  502 + || "PROCESS_STD_AGMT".equals(data.getType()))) { // 只有经销(外贸、加工)标准合同才修改状态
500 503 updateWrapper.set(ContractDistributorStandard::getStatus, "STANDARD")
501 504 .set(ContractDistributorStandard::getStandardizedAt, LocalDateTime.now());
502 505 }
... ... @@ -820,6 +823,14 @@ public class ContractDistributorStandardServiceImpl extends
820 823 OpLogUtil.setExtra(vo);
821 824 }
822 825
  826 + public List<String> getNoContractSigned(List<String> buyerList) {
  827 + return getBaseMapper().getNoContractSigned(buyerList);
  828 + }
  829 +
  830 + public List<String> getContractSigned(List<String> buyerList) {
  831 + return getBaseMapper().getContractSigned(buyerList);
  832 + }
  833 +
823 834 @CacheEvict(value = ContractDistributorStandard.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
824 835 @Override
825 836 public void cleanCacheByKey(Serializable key) {
... ...
1 1 package com.lframework.xingyun.sc.impl.contract;
2 2
  3 +import com.baomidou.mybatisplus.core.conditions.Wrapper;
3 4 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 5 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 6 import com.github.pagehelper.PageInfo;
  7 +import com.lframework.starter.bpm.dto.FlowTaskDto;
  8 +import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
  9 +import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
  10 +import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
6 11 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
7 12 import com.lframework.starter.common.utils.Assert;
8 13 import com.lframework.starter.common.utils.ObjectUtil;
9 14 import com.lframework.starter.web.core.annotations.oplog.OpLog;
10 15 import com.lframework.starter.web.core.components.resp.PageResult;
  16 +import com.lframework.starter.web.core.components.security.SecurityUtil;
11 17 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
12 18 import com.lframework.starter.web.core.utils.IdUtil;
13 19 import com.lframework.starter.web.core.utils.OpLogUtil;
14 20 import com.lframework.starter.web.core.utils.PageHelperUtil;
15 21 import com.lframework.starter.web.core.utils.PageResultUtil;
16 22 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  23 +import com.lframework.xingyun.sc.entity.CustomerCredit;
17 24 import com.lframework.xingyun.sc.entity.SpecLockDelayApplication;
  25 +import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
18 26 import com.lframework.xingyun.sc.mappers.SpecLockDelayApplicationMapper;
19 27 import com.lframework.xingyun.sc.service.contract.SpecLockDelayApplicationService;
20 28 import com.lframework.xingyun.sc.vo.contract.createVo.CreateSpecLockDelayApplicationVo;
21 29 import com.lframework.xingyun.sc.vo.contract.queryVo.QuerySpecLockDelayApplicationVo;
22 30 import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateSpecLockDelayApplicationVo;
  31 +import org.apache.commons.collections.CollectionUtils;
  32 +import org.apache.commons.lang3.StringUtils;
  33 +import org.springframework.beans.factory.annotation.Autowired;
23 34 import org.springframework.cache.annotation.CacheEvict;
24 35 import org.springframework.cache.annotation.Cacheable;
25 36 import org.springframework.stereotype.Service;
26 37 import org.springframework.transaction.annotation.Transactional;
27 38
28 39 import java.io.Serializable;
  40 +import java.time.LocalDateTime;
29 41 import java.util.List;
  42 +import java.util.stream.Collectors;
30 43
31 44 @Service
32 45 public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecLockDelayApplicationMapper, SpecLockDelayApplication> implements SpecLockDelayApplicationService {
33 46
  47 + private static final String SPEC_LOCK_DELAY_FLAY = "SPEC_LOCK_DELAY"; // 未锁规格申请单审批
  48 +
  49 + @Autowired
  50 + private FlowInstanceWrapperService flowInstanceWrapperService;
  51 + @Autowired
  52 + private FlowTaskWrapperMapper flowTaskWrapperMapper;
  53 +
34 54 @Override
35 55 public PageResult<SpecLockDelayApplication> query(Integer pageIndex, Integer pageSize, QuerySpecLockDelayApplicationVo vo) {
36 56
... ... @@ -40,6 +60,18 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL
40 60 PageHelperUtil.startPage(pageIndex, pageSize);
41 61 List<SpecLockDelayApplication> datas = this.query(vo);
42 62
  63 + if (CollectionUtils.isNotEmpty(datas)) {
  64 + // 获取当前人员的待办任务数据
  65 + List<FlowTaskDto> flowTaskList = flowTaskWrapperMapper.queryTodoList(new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
  66 + if (CollectionUtils.isEmpty(flowTaskList)) {
  67 + return new PageResult<>();
  68 + }
  69 + List<String> ids = flowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toList());
  70 + for (SpecLockDelayApplication specLockDelayApplication : datas) {
  71 + specLockDelayApplication.setShowExamine(ids.contains(specLockDelayApplication.getId()));
  72 + }
  73 + }
  74 +
43 75 return PageResultUtil.convert(new PageInfo<>(datas));
44 76 }
45 77
... ... @@ -67,13 +99,15 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL
67 99 data.setSpecLockDate(vo.getSpecLockDate());
68 100 data.setApplicationCount(vo.getApplicationCount());
69 101 data.setDelayReason(vo.getDelayReason());
70   - data.setApprovalStatus(vo.getApprovalStatus());
  102 + data.setApprovalStatus(CustomerDevelopStatus.AUDIT.name()); // 新建完成直接提交审核
71 103
72 104 getBaseMapper().insert(data);
73 105
74 106 OpLogUtil.setVariable("id", data.getId());
75 107 OpLogUtil.setExtra(vo);
76 108
  109 + // 开启审核
  110 + flowInstanceWrapperService.startInstance(SPEC_LOCK_DELAY_FLAY, data.getId(), SPEC_LOCK_DELAY_FLAY, data);
77 111 return data.getId();
78 112 }
79 113
... ... @@ -87,18 +121,88 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL
87 121 throw new DefaultClientException("锁价无规格操作申请单不存在!");
88 122 }
89 123
  124 + if (!CustomerDevelopStatus.REFUSE.name().equals(data.getApprovalStatus())) {
  125 + throw new DefaultClientException(CustomerDevelopStatus.getDescByNameSafe(data.getApprovalStatus()) + "的锁价无规格操作申请单不允许修改!");
  126 + }
  127 +
90 128 LambdaUpdateWrapper<SpecLockDelayApplication> updateWrapper = Wrappers.lambdaUpdate(SpecLockDelayApplication.class)
91   - .set(SpecLockDelayApplication::getContractId, vo.getContractId())
92 129 .set(SpecLockDelayApplication::getSpecLockDate, vo.getSpecLockDate())
93   - .set(SpecLockDelayApplication::getApplicationCount, vo.getApplicationCount())
94 130 .set(SpecLockDelayApplication::getDelayReason, vo.getDelayReason())
95   - .set(SpecLockDelayApplication::getApprovalStatus, vo.getApprovalStatus())
96 131 .eq(SpecLockDelayApplication::getId, vo.getId());
97 132
98 133 getBaseMapper().update(updateWrapper);
99 134
100 135 OpLogUtil.setVariable("id", data.getId());
101 136 OpLogUtil.setExtra(vo);
  137 +
  138 + // 编辑完成再次开启审核
  139 + flowInstanceWrapperService.startInstance(SPEC_LOCK_DELAY_FLAY, data.getId(), SPEC_LOCK_DELAY_FLAY, data);
  140 + }
  141 +
  142 + @Override
  143 + @OpLog(type = OtherOpLogType.class, name = "锁价无规格操作申请单审批完成,ID:{}, 审批状态:{}", params = {"#id", "#approvedStatus"})
  144 + @Transactional(rollbackFor = Exception.class)
  145 + public void updateAuditStatus(String id, String approvedStatus) {
  146 + if (StringUtils.isBlank(id) || StringUtils.isBlank(approvedStatus)) {
  147 + return;
  148 + }
  149 +
  150 + Wrapper<SpecLockDelayApplication> wrapper = Wrappers.lambdaUpdate(SpecLockDelayApplication.class)
  151 + .set(SpecLockDelayApplication::getApprovalStatus, approvedStatus)
  152 + .set(SpecLockDelayApplication::getApprovedAt, LocalDateTime.now())
  153 + .set(SpecLockDelayApplication::getApproverId, SecurityUtil.getCurrentUser().getId())
  154 + .eq(SpecLockDelayApplication::getId, id);
  155 +
  156 + getBaseMapper().update(wrapper);
  157 +
  158 + UpdateSpecLockDelayApplicationVo vo = new UpdateSpecLockDelayApplicationVo();
  159 + vo.setId(id);
  160 + vo.setApprovalStatus(approvedStatus);
  161 + vo.setApprovedAt(LocalDateTime.now());
  162 + vo.setApproverId(SecurityUtil.getCurrentUser().getId());
  163 +
  164 + OpLogUtil.setVariable("id", id);
  165 + OpLogUtil.setExtra(vo);
  166 +
  167 + cleanCacheByKey(id);
  168 + }
  169 +
  170 + @Override
  171 + @OpLog(type = OtherOpLogType.class, name = "锁价无规格操作申请单取消,ID:{}", params = {"#id"})
  172 + @Transactional(rollbackFor = Exception.class)
  173 + public void cancelApplication(String id) {
  174 + SpecLockDelayApplication data = getBaseMapper().selectById(id);
  175 + if (ObjectUtil.isNull(data)) {
  176 + throw new DefaultClientException("锁价无规格操作申请单不存在!");
  177 + }
  178 +
  179 + if (CustomerDevelopStatus.CANCEL.name().equals(data.getApprovalStatus())) {
  180 + throw new DefaultClientException("锁价无规格操作申请单已经取消!");
  181 + }
  182 +
  183 + if (!CustomerDevelopStatus.REFUSE.name().equals(data.getApprovalStatus())) {
  184 + throw new DefaultClientException(CustomerDevelopStatus.getDescByNameSafe(data.getApprovalStatus()) + "的锁价无规格操作申请单不允许取消!");
  185 + }
  186 +
  187 + Wrapper<SpecLockDelayApplication> wrapper = Wrappers.lambdaUpdate(SpecLockDelayApplication.class)
  188 + .set(SpecLockDelayApplication::getApprovalStatus, CustomerDevelopStatus.CANCEL.name())
  189 + .set(SpecLockDelayApplication::getApprovedAt, LocalDateTime.now())
  190 + .set(SpecLockDelayApplication::getApproverId, SecurityUtil.getCurrentUser().getId())
  191 + .eq(SpecLockDelayApplication::getId, id);
  192 +
  193 + getBaseMapper().update(wrapper);
  194 +
  195 + UpdateSpecLockDelayApplicationVo vo = new UpdateSpecLockDelayApplicationVo();
  196 + vo.setId(id);
  197 + vo.setApprovalStatus(CustomerDevelopStatus.CANCEL.name());
  198 + vo.setApprovedAt(LocalDateTime.now());
  199 + vo.setApproverId(SecurityUtil.getCurrentUser().getId());
  200 +
  201 +
  202 + OpLogUtil.setVariable("id", id);
  203 + OpLogUtil.setExtra(vo);
  204 +
  205 + cleanCacheByKey(id);
102 206 }
103 207
104 208 @CacheEvict(value = SpecLockDelayApplication.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
... ...
... ... @@ -296,6 +296,8 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
296 296 data.setCompanySuggestedCategory(vo.getCompanySuggestedCategory());
297 297 }
298 298 data.setStatus(vo.getStatus());
  299 + //新增默认正常
  300 + data.setFrozenStatus("NORMAL");
299 301
300 302 getBaseMapper().insert(data);
301 303
... ... @@ -913,7 +915,7 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
913 915 UpdateCustomerCreditVo updateCustomerCreditVo = objectMapper.readValue(json, UpdateCustomerCreditVo.class);
914 916 // 使用转换后的对象
915 917 System.out.println(updateCustomerCreditVo);
916   - updateNoFlowInstance(updateCustomerCreditVo);
  918 + updatePartNoFlowInstance(updateCustomerCreditVo);
917 919
918 920 } catch (JsonProcessingException e) {
919 921 e.printStackTrace();
... ... @@ -1076,6 +1078,32 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
1076 1078 cleanCacheByKey(vo.getId());
1077 1079 }
1078 1080
  1081 + @OpLog(type = OtherOpLogType.class, name = "审核中修改客户资信表不走审核,ID:{}", params = {"#id"})
  1082 + @Transactional(rollbackFor = Exception.class)
  1083 + @Override
  1084 + public void updatePartNoFlowInstance(UpdateCustomerCreditVo vo) {
  1085 +
  1086 + CustomerCredit data = customerCreditMapper.findById(vo.getId());
  1087 + if (ObjectUtil.isNull(data)) {
  1088 + throw new DefaultClientException("客户资信表不存在!");
  1089 + }
  1090 + LambdaUpdateWrapper<CustomerCredit> updateWrapper = Wrappers.lambdaUpdate(CustomerCredit.class)
  1091 + .set(CustomerCredit::getCompanySettlementPeriod, StringUtil.isBlank(vo.getCompanySettlementPeriod()) ? null : vo.getCompanySettlementPeriod())
  1092 + .set(CustomerCredit::getCompanyCreditLimit, StringUtil.isBlank(vo.getCompanyCreditLimit()) ? null : vo.getCompanyCreditLimit())
  1093 + .set(CustomerCredit::getCompanyMaterialSupplyPlan, StringUtil.isBlank(vo.getCompanyMaterialSupplyPlan()) ? null : vo.getCompanyMaterialSupplyPlan())
  1094 + .set(CustomerCredit::getCompanySuggestedCategory, vo.getCompanySuggestedCategory())
  1095 + .set(CustomerCredit::getBusinessFileName, StringUtil.isBlank(vo.getBusinessFileName()) ? null : vo.getBusinessFileName())
  1096 + .set(CustomerCredit::getBusinessFileId, StringUtil.isBlank(vo.getBusinessFileId()) ? null : vo.getBusinessFileId())
  1097 + .set(CustomerCredit::getShareholderFileName, StringUtil.isBlank(vo.getShareholderFileName()) ? null : vo.getShareholderFileName())
  1098 + .set(CustomerCredit::getShareholderFileId, StringUtil.isBlank(vo.getShareholderFileId()) ? null : vo.getShareholderFileId())
  1099 + .eq(CustomerCredit::getId, vo.getId());
  1100 +
  1101 + getBaseMapper().update(updateWrapper);
  1102 + OpLogUtil.setVariable("id", data.getId());
  1103 + OpLogUtil.setExtra(vo);
  1104 + cleanCacheByKey(vo.getId());
  1105 + }
  1106 +
1079 1107 @OpLog(type = OtherOpLogType.class, name = "更新状态,ID:{}", params = {"#id"})
1080 1108 @Transactional(rollbackFor = Exception.class)
1081 1109 @Override
... ... @@ -1135,6 +1163,37 @@ public class CustomerCreditServiceImpl extends BaseMpServiceImpl<CustomerCreditM
1135 1163 cleanCacheByKey(id);
1136 1164 }
1137 1165
  1166 + @OpLog(type = OtherOpLogType.class, name = "批量更新企业操作类型,ID:{}", params = {"#id"})
  1167 + @Transactional(rollbackFor = Exception.class)
  1168 + @Override
  1169 + public void updateEnterpriseOperationType(List<String> ids, String enterpriseOperationType) {
  1170 + if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(enterpriseOperationType)) {
  1171 + return;
  1172 + }
  1173 + getBaseMapper().updateEnterpriseOperationType(ids, enterpriseOperationType);
  1174 + }
  1175 +
  1176 +
  1177 + @OpLog(type = OtherOpLogType.class, name = "批量更新冻结状态,ID:{}", params = {"#id"})
  1178 + @Transactional(rollbackFor = Exception.class)
  1179 + @Override
  1180 + public void updateFrozenStatus(List<String> ids, String frozenStatus) {
  1181 + if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(frozenStatus)) {
  1182 + return;
  1183 + }
  1184 + getBaseMapper().updateFrozenStatus(ids, frozenStatus);
  1185 + }
  1186 +
  1187 + @OpLog(type = OtherOpLogType.class, name = "批量更新冻结状态,ID:{}", params = {"#id"})
  1188 + @Transactional(rollbackFor = Exception.class)
  1189 + @Override
  1190 + public List<String> getNeedFrozenIds(List<String> ids, String createTime) {
  1191 + if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(createTime)) {
  1192 + return null;
  1193 + }
  1194 + return getBaseMapper().getNeedFrozenIds(ids, createTime);
  1195 + }
  1196 +
1138 1197 @OpLog(type = OtherOpLogType.class, name = "删除客户资信表,ID:{}", params = {"#id"})
1139 1198 @Transactional(rollbackFor = Exception.class)
1140 1199 @Override
... ...
... ... @@ -37,7 +37,7 @@ public class FlowTaskServiceImpl implements FlowTaskService {
37 37 UpdateCustomerCreditVo updateCustomerCreditVo = JsonUtil.parseObject(json, UpdateCustomerCreditVo.class);
38 38 // 使用转换后的对象
39 39 System.out.println(updateCustomerCreditVo);
40   - customerCreditService.updateNoFlowInstance(updateCustomerCreditVo);
  40 + customerCreditService.updatePartNoFlowInstance(updateCustomerCreditVo);
41 41 customerCreditService.cleanCacheByKey(updateCustomerCreditVo.getId());
42 42 } catch (JsonProcessingException e) {
43 43 e.printStackTrace();
... ...
... ... @@ -23,4 +23,21 @@ public interface ContractDistributorStandardMapper extends BaseMapper<ContractDi
23 23 List<ContractDistributorStandard> query(@Param("vo") QueryContractDistributorStandardVo vo);
24 24
25 25 List<ContractDistributorStandard> getCustomerSpecificQualityRequirements(@Param("customerId") String customerId, @Param("productIdList") List<String> productIdList);
  26 +
  27 + /**
  28 + * 获取一年内未签订合同的企业
  29 + *
  30 + * @param buyerList 企业id集合
  31 + * @return 一年内未签订合同的企业
  32 + */
  33 + List<String> getNoContractSigned(@Param("buyerList") List<String> buyerList);
  34 +
  35 + /**
  36 + * 获取一年内签订过合同的企业
  37 + *
  38 + * @param buyerList 企业id集合
  39 + * @return 一年内未签订合同的企业
  40 + */
  41 + List<String> getContractSigned(@Param("buyerList") List<String> buyerList);
  42 +
26 43 }
... ...
... ... @@ -38,4 +38,23 @@ public interface CustomerCreditMapper extends BaseMapper<CustomerCredit> {
38 38 * @return 已使用编码
39 39 */
40 40 Set<String> getGenerateCode(@Param("code") String code);
  41 +
  42 + /**
  43 + * 批量更新企业操作类型
  44 + *
  45 + * @param ids 资信ids
  46 + * @param enterpriseOperationType 企业操作类型
  47 + */
  48 + void updateEnterpriseOperationType(@Param("ids") List<String> ids, @Param("enterpriseOperationType") String enterpriseOperationType);
  49 +
  50 + /**
  51 + * 批量更新冻结状态
  52 + *
  53 + * @param ids 资信ids
  54 + * @param frozenStatus 冻结状态
  55 + */
  56 + void updateFrozenStatus(@Param("ids") List<String> ids, @Param("frozenStatus") String frozenStatus);
  57 +
  58 +
  59 + List<String> getNeedFrozenIds(@Param("ids") List<String> ids, @Param("createTime") String createTime);
41 60 }
... ...
... ... @@ -6,6 +6,7 @@ import com.lframework.starter.web.core.components.resp.PageResult;
6 6 import com.lframework.xingyun.sc.vo.contract.createVo.CreateContractDistributorStandardVo;
7 7 import com.lframework.xingyun.sc.vo.contract.queryVo.QueryContractDistributorStandardVo;
8 8 import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateContractDistributorStandardVo;
  9 +import org.apache.ibatis.annotations.Param;
9 10
10 11 import java.util.List;
11 12
... ... @@ -104,4 +105,20 @@ public interface ContractDistributorStandardService extends BaseMpService<Contra
104 105 */
105 106 void specificationLock(UpdateContractDistributorStandardVo vo);
106 107
107   -}
\ No newline at end of file
  108 + /**
  109 + * 获取一年内未签订合同的企业
  110 + *
  111 + * @param buyerList 企业id集合
  112 + * @return 一年内未签订合同的企业
  113 + */
  114 + List<String> getNoContractSigned(List<String> buyerList);
  115 +
  116 + /**
  117 + * 获取一年内签订过合同的企业
  118 + *
  119 + * @param buyerList 企业id集合
  120 + * @return 一年内未签订合同的企业
  121 + */
  122 + List<String> getContractSigned(List<String> buyerList);
  123 +
  124 +}
... ...
... ... @@ -52,5 +52,20 @@ public interface SpecLockDelayApplicationService extends BaseMpService<SpecLockD
52 52 */
53 53 void update(UpdateSpecLockDelayApplicationVo vo);
54 54
  55 + /**
  56 + * 更新审核状态
  57 + *
  58 + * @param id
  59 + * @param approvedStatus
  60 + */
  61 + void updateAuditStatus(String id, String approvedStatus);
  62 +
  63 + /**
  64 + * 取消申请
  65 + *
  66 + * @param id
  67 + */
  68 + void cancelApplication(String id);
  69 +
55 70 }
56 71
... ...
... ... @@ -8,6 +8,7 @@ import com.lframework.xingyun.sc.vo.customer.credit.CreateCustomerCreditVo;
8 8 import com.lframework.xingyun.sc.vo.customer.credit.QueryCustomerCreditVo;
9 9 import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo;
10 10 import freemarker.template.TemplateException;
  11 +import org.apache.ibatis.annotations.Param;
11 12
12 13 import java.io.IOException;
13 14 import java.util.List;
... ... @@ -65,6 +66,8 @@ public interface CustomerCreditService extends BaseMpService<CustomerCredit> {
65 66 */
66 67 void updateNoFlowInstance(UpdateCustomerCreditVo vo);
67 68
  69 + void updatePartNoFlowInstance(UpdateCustomerCreditVo vo);
  70 +
68 71
69 72 /**
70 73 * 更新状态
... ... @@ -88,6 +91,31 @@ public interface CustomerCreditService extends BaseMpService<CustomerCredit> {
88 91 void cancel(String id);
89 92
90 93 /**
  94 + * 批量更新企业操作类型
  95 + *
  96 + * @param ids 主键
  97 + * @param enterpriseOperationType 企业操作类型
  98 + */
  99 + void updateEnterpriseOperationType(List<String> ids, String enterpriseOperationType);
  100 +
  101 + /**
  102 + * 批量更新冻结状态
  103 + *
  104 + * @param ids 主键
  105 + * @param frozenStatus 冻结状态
  106 + */
  107 + void updateFrozenStatus(List<String> ids, String frozenStatus);
  108 +
  109 + /**
  110 + * 获取需要冻结的客户资信id
  111 + *
  112 + * @param ids 资信id集合
  113 + * @param createTime 创建时间
  114 + * @return 需要冻结的客户资信id集合
  115 + */
  116 + List<String> getNeedFrozenIds(List<String> ids, String createTime);
  117 +
  118 + /**
91 119 * 根据ID删除
92 120 * @param id
93 121 * @return
... ...
... ... @@ -8,6 +8,7 @@ import org.hibernate.validator.constraints.Length;
8 8
9 9 import java.io.Serializable;
10 10 import java.time.LocalDate;
  11 +import java.time.LocalDateTime;
11 12
12 13 @Data
13 14 public class UpdateSpecLockDelayApplicationVo implements BaseVo, Serializable {
... ... @@ -55,4 +56,15 @@ public class UpdateSpecLockDelayApplicationVo implements BaseVo, Serializable {
55 56 @Length(message = "审核状态最多允许50个字符!")
56 57 private String approvalStatus;
57 58
  59 + /**
  60 + * 审核人
  61 + */
  62 + @ApiModelProperty(value = "审核人")
  63 + private String approverId;
  64 +
  65 + /**
  66 + * 审核时间
  67 + */
  68 + @ApiModelProperty(value = "审核时间")
  69 + private LocalDateTime approvedAt;
58 70 }
... ...
... ... @@ -397,4 +397,16 @@ public class CreateCustomerCreditVo implements BaseVo, Serializable {
397 397 @ApiModelProperty("是否为导入")
398 398 private String importType;
399 399
  400 + /**
  401 + * 企业操作类型
  402 + */
  403 + @ApiModelProperty("企业操作类型")
  404 + private String enterpriseOperationType;
  405 +
  406 + /**
  407 + * 冻结状态(正常:NORMAL,冻结:FROZEN)
  408 + */
  409 + @ApiModelProperty(value = "冻结状态")
  410 + private String frozenStatus;
  411 +
400 412 }
... ...
... ... @@ -76,4 +76,22 @@ public class QueryCustomerCreditVo extends PageVo implements BaseVo, Serializabl
76 76 @ApiModelProperty("导出类型")
77 77 private String exportType;
78 78
  79 + /**
  80 + * 企业操作类型
  81 + */
  82 + @ApiModelProperty("企业操作类型")
  83 + private String enterpriseOperationType;
  84 +
  85 + /**
  86 + * 冻结状态(正常:NORMAL,冻结:FROZEN)
  87 + */
  88 + @ApiModelProperty(value = "冻结状态")
  89 + private String frozenStatus;
  90 +
  91 + /**
  92 + * 创建时间
  93 + */
  94 + @ApiModelProperty(value = "创建时间")
  95 + private String createTimeStr;
  96 +
79 97 }
... ...
... ... @@ -458,4 +458,16 @@ public class UpdateCustomerCreditVo implements BaseVo, Serializable {
458 458 @ApiModelProperty(value = "营销中心主管")
459 459 private String marketingCenterSupervisor;
460 460
  461 + /**
  462 + * 企业操作类型
  463 + */
  464 + @ApiModelProperty("企业操作类型")
  465 + private String enterpriseOperationType;
  466 +
  467 + /**
  468 + * 冻结状态(正常:NORMAL,冻结:FROZEN)
  469 + */
  470 + @ApiModelProperty(value = "冻结状态")
  471 + private String frozenStatus;
  472 +
461 473 }
... ...
... ... @@ -189,4 +189,40 @@
189 189 WHERE rn = 1
190 190 ORDER BY create_time;
191 191 </select>
  192 +
  193 + <select id="getNoContractSigned" resultType="java.lang.String">
  194 + SELECT DISTINCT buyer
  195 + FROM (
  196 + SELECT
  197 + buyer,
  198 + formalized_at,
  199 + ROW_NUMBER() OVER (PARTITION BY buyer ORDER BY formalized_at DESC) AS rn
  200 + FROM tbl_contract_distributor_standard
  201 + WHERE formalized_at is not null
  202 + and buyer in
  203 + <foreach collection="buyerList" open="(" separator="," close=")" item="item">
  204 + #{item}
  205 + </foreach>
  206 + ) t
  207 + WHERE rn = 1
  208 + AND DATE(formalized_at) &lt; DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
  209 + </select>
  210 +
  211 + <select id="getContractSigned" resultType="java.lang.String">
  212 + SELECT DISTINCT buyer
  213 + FROM (
  214 + SELECT
  215 + buyer,
  216 + formalized_at,
  217 + ROW_NUMBER() OVER (PARTITION BY buyer ORDER BY formalized_at DESC) AS rn
  218 + FROM tbl_contract_distributor_standard
  219 + WHERE formalized_at is not null
  220 + and buyer in
  221 + <foreach collection="buyerList" open="(" separator="," close=")" item="item">
  222 + #{item}
  223 + </foreach>
  224 + ) t
  225 + WHERE rn = 1
  226 + AND DATE(formalized_at) >= DATE_SUB(CURDATE(), INTERVAL 1 YEAR);
  227 + </select>
192 228 </mapper>
... ...
... ... @@ -64,6 +64,8 @@
64 64 <result column="marketing_department_supervisor" property="marketingDepartmentSupervisor"/>
65 65 <result column="marketing_center_supervisor" property="marketingCenterSupervisor"/>
66 66 <result column="status" property="status"/>
  67 + <result column="enterprise_operation_type" property="enterpriseOperationType"/>
  68 + <result column="frozen_status" property="frozenStatus"/>
67 69 <result column="create_by_id" property="createById"/>
68 70 <result column="create_by" property="createBy"/>
69 71 <result column="update_by_id" property="updateById"/>
... ... @@ -135,6 +137,8 @@
135 137 tb.marketing_department_supervisor,
136 138 tb.marketing_center_supervisor,
137 139 tb.shareholder_file_id,
  140 + tb.enterprise_operation_type,
  141 + tb.frozen_status,
138 142 tb.create_by_id,
139 143 tb.create_by,
140 144 tb.update_by_id,
... ... @@ -174,6 +178,15 @@
174 178 <if test="vo.statusCancel != null and vo.statusCancel != ''">
175 179 AND tb.status != #{vo.statusCancel}
176 180 </if>
  181 + <if test="vo.enterpriseOperationType != null and vo.enterpriseOperationType != ''">
  182 + AND tb.enterprise_operation_type = #{vo.enterpriseOperationType}
  183 + </if>
  184 + <if test="vo.frozenStatus != null and vo.frozenStatus != ''">
  185 + AND tb.frozen_status = #{vo.frozenStatus}
  186 + </if>
  187 + <if test="vo.createTimeStr != null and vo.createTimeStr != ''">
  188 + AND tb.create_time &lt; #{vo.createTimeStr}
  189 + </if>
177 190 </where>
178 191 </select>
179 192
... ... @@ -196,4 +209,49 @@
196 209 </if>
197 210 </where>
198 211 </select>
  212 +
  213 + <update id="updateEnterpriseOperationType">
  214 + UPDATE customer_credit
  215 + SET enterprise_operation_type = #{enterpriseOperationType}
  216 + WHERE id in
  217 + <foreach collection="ids" open="(" separator="," close=")" item="item">
  218 + #{item}
  219 + </foreach>
  220 + </update>
  221 +
  222 + <update id="updateFrozenStatus">
  223 + UPDATE customer_credit
  224 + SET frozen_status = #{frozenStatus}
  225 + WHERE id in
  226 + <foreach collection="ids" open="(" separator="," close=")" item="item">
  227 + #{item}
  228 + </foreach>
  229 + </update>
  230 +
  231 + <select id="getNeedFrozenIds" resultType="String">
  232 + SELECT c.id
  233 + FROM customer_credit c
  234 + LEFT JOIN (
  235 + SELECT
  236 + h.credit_id,
  237 + MAX(h.create_time) AS latest_create_time -- 直接取最大时间
  238 + FROM customer_credit_history h
  239 + WHERE h.id LIKE '%_01'
  240 + AND h.credit_id IN
  241 + <foreach collection="ids" item="item" open="(" separator="," close=")">
  242 + #{item}
  243 + </foreach>
  244 + GROUP BY h.credit_id
  245 + ) latest_h ON c.id = latest_h.credit_id
  246 + WHERE c.id IN
  247 + <foreach collection="ids" item="item" open="(" separator="," close=")">
  248 + #{item}
  249 + </foreach>
  250 + AND c.status = 'PASS'
  251 + AND (
  252 + latest_h.latest_create_time IS NULL -- 无 history 记录
  253 + OR latest_h.latest_create_time &lt; #{createTime} -- 有记录且最新时间小于createTime
  254 + );
  255 + </select>
  256 +
199 257 </mapper>
... ...