|
|
@ -16,7 +16,6 @@ |
|
|
|
*/ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.epmet.common.enu.PointUnitEnum; |
|
|
@ -196,14 +195,23 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public InitPointRuleResultDTO initPointRule() { |
|
|
|
public InitPointRuleResultDTO initPointRule(String customerId) { |
|
|
|
//得到所有客户Id
|
|
|
|
Result<List<CustomerDTO>> customerListResult = operCrmOpenFeignClient.getAllCustomerList(); |
|
|
|
log.info("initPointRule operCrmOpenFeignClient.getAllCustomerList result:{}",JSON.toJSONString(customerListResult)); |
|
|
|
if (!customerListResult.success() || CollectionUtils.isEmpty(customerListResult.getData())) { |
|
|
|
throw new RenException("获取所有客户列表失败"); |
|
|
|
List<CustomerDTO> customerDTOList = null; |
|
|
|
if (StringUtils.isBlank(customerId)){ |
|
|
|
Result<List<CustomerDTO>> customerListResult = operCrmOpenFeignClient.getAllCustomerList(); |
|
|
|
log.info("initPointRule operCrmOpenFeignClient.getAllCustomerList result:{}",JSON.toJSONString(customerListResult)); |
|
|
|
if (!customerListResult.success() || CollectionUtils.isEmpty(customerListResult.getData())) { |
|
|
|
throw new RenException("获取所有客户列表失败"); |
|
|
|
} |
|
|
|
customerDTOList = customerListResult.getData(); |
|
|
|
}else{ |
|
|
|
customerDTOList = new ArrayList<>(); |
|
|
|
CustomerDTO customerDTO = new CustomerDTO(); |
|
|
|
customerDTO.setId(customerId); |
|
|
|
customerDTOList.add(customerDTO); |
|
|
|
} |
|
|
|
List<CustomerDTO> customerDTOList = customerListResult.getData(); |
|
|
|
|
|
|
|
//获取默认规则列表
|
|
|
|
List<PointRuleDefaultEntity> ruleDefaultEntities = pointRuleDefaultDao.selectList(null); |
|
|
|
if (CollectionUtils.isEmpty(ruleDefaultEntities)) { |
|
|
@ -221,7 +229,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul |
|
|
|
//key :: customerId || value :: 客户规则集合
|
|
|
|
Map<String,List<PointRuleEntity>> customerRuleMap = |
|
|
|
customerRule.stream().collect(Collectors.groupingBy(PointRuleEntity :: getCustomerId)); |
|
|
|
customerRuleMap.forEach((customerId,ruleList) -> { |
|
|
|
customerRuleMap.forEach((cId,ruleList) -> { |
|
|
|
if(null != ruleList){ |
|
|
|
List<String> event = new LinkedList<>(defaultEventCodeList); |
|
|
|
//取差集,event只剩下当前客户没有的积分规则
|
|
|
@ -234,7 +242,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul |
|
|
|
entity.setCreatedTime(new Date()); |
|
|
|
entity.setUpdatedBy(""); |
|
|
|
entity.setUpdatedTime(new Date()); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
entity.setCustomerId(cId); |
|
|
|
insertList.add(entity); |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
@ -281,6 +289,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul |
|
|
|
InitPointRuleResultDTO result = new InitPointRuleResultDTO(); |
|
|
|
result.setCustomerTotal(customerDTOList.size()); |
|
|
|
result.setInitedTotal(insertList.size()); |
|
|
|
result.setInitedDetail(JSON.toJSONString(insertList)); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|