Browse Source

注释修改

dev_shibei_match
wangchao 4 years ago
parent
commit
2ec8958421
  1. 10
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java

10
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/PointRuleServiceImpl.java

@ -197,12 +197,14 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
@Override
@Transactional(rollbackFor = Exception.class)
public InitPointRuleResultDTO initPointRule() {
//得到所有客户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 = customerListResult.getData();
//获取默认规则列表
List<PointRuleDefaultEntity> ruleDefaultEntities = pointRuleDefaultDao.selectList(null);
if (CollectionUtils.isEmpty(ruleDefaultEntities)) {
log.warn("initPointRule pointRuleDefaultDao.selectList return empty");
@ -211,15 +213,18 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
List<PointRuleEntity> insertList = new ArrayList<>();
//获取全部默认规则code集合
List<String> defaultEventCodeList = ruleDefaultEntities.stream().map(PointRuleDefaultEntity :: getEventCode).distinct().collect(Collectors.toList());
//获取所有客户的积分规则
List<PointRuleEntity> customerRule = baseDao.selectList(null);
if(!CollectionUtils.isEmpty(customerRule)){
//key :: customerId || value :: 客户规则集合
Map<String,List<PointRuleEntity>> customerRuleMap =
customerRule.stream().collect(Collectors.groupingBy(PointRuleEntity :: getCustomerId));
customerRuleMap.forEach((customerId,ruleList) -> {
if(null != ruleList){
List<String> event = new LinkedList<>(defaultEventCodeList);
//取差集
//取差集,event只剩下当前客户没有的积分规则
event.removeAll(ruleList.stream().map(PointRuleEntity :: getEventCode).distinct().collect(Collectors.toList()));
if(!CollectionUtils.isEmpty(event)){
ruleDefaultEntities.stream().filter(rule -> event.contains(rule.getEventCode())).map(o -> {
@ -238,7 +243,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
});
}
//从未被初始化的customerId
//被初始化的customerId
List<String> haveInitCustomerIds = baseDao.selectCustomerIds();
if (haveInitCustomerIds == null) {
haveInitCustomerIds = new ArrayList<>();
@ -249,6 +254,7 @@ public class PointRuleServiceImpl extends BaseServiceImpl<PointRuleDao, PointRul
if (haveInitCustomerIds.contains(customerDTO.getId())) {
continue;
}
//对从未被初始化过积分规则的客户进行积分规则初始化
PointRuleEntity entity = ConvertUtils.sourceToTarget(defaultRule, PointRuleEntity.class);
entity.setId("");
entity.setCreatedBy("INITIALIZATION");

Loading…
Cancel
Save