Commit 7a5869e6 by guojuxing

装修配置挑战:添加可用积分已经会员卡列表数据调整

parent 59ab22aa
......@@ -20,10 +20,6 @@ public class AppletCardDTO implements Serializable{
private Long cardConfigId;
private String cardName;
/**
* 是否是子卡
*/
private Boolean isSub;
/**
* 子卡列表
......
......@@ -147,13 +147,9 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
return ServiceResponse.failure(appletCardResult.getCode(), appletCardResult.getMessage());
}
List<AppletCardDTO> appletCardList = appletCardResult.getResult();
Map<String, Boolean> appletCardMap = new HashMap<>(16);
Map<String, List<AppletCardDTO>> appletMainCardMap = new HashMap<>(16);
Map<String, List<AppletCardDTO>> appletCardMap = new HashMap<>(16);
for (AppletCardDTO cardDTO : appletCardList) {
appletCardMap.put(cardDTO.getCardConfigId().toString(), cardDTO.getIsSub());
if (!cardDTO.getIsSub()) {
appletMainCardMap.put(cardDTO.getCardConfigId().toString(), cardDTO.getSubList());
}
appletCardMap.put(cardDTO.getCardConfigId().toString(), cardDTO.getSubList());
}
//需要校验的数值集合
......@@ -189,7 +185,10 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
//会员任务
appletDataAssetArea.setMemberTask(totalIntegral);
} else {
Boolean isSub = appletCardMap.get(totalIntegral);
//总积分会员卡下面的子卡列表
List<AppletCardDTO> totalIntegralSubList = appletCardMap.get(totalIntegral);
//是否没有子卡列表
boolean isSub = CollectionUtils.isEmpty(totalIntegralSubList);
if (isSub) {
//如果总积分选择的是子卡,则下面的只能是子卡
appletDataAssetArea.setAvailableIntegral(totalIntegral);
......@@ -201,14 +200,16 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
appletDataAssetArea.setMemberTask(totalIntegral);
} else {
//如果总积分是主卡,则可用积分可以是主卡,也可以下面子卡
Boolean isSubOfAvailableIntegral = appletCardMap.get(availableIntegral);
List<AppletCardDTO> subListTemp = appletMainCardMap.get(totalIntegral);
List<AppletCardDTO> availabelIntegralSubList = appletCardMap.get(availableIntegral);
List<AppletCardDTO> subListTemp = appletCardMap.get(totalIntegral);
Set<String> subSet = new HashSet<>();
if (CollectionUtils.isNotEmpty(subListTemp)) {
for (AppletCardDTO subSetTemp : subListTemp) {
subSet.add(subSetTemp.getCardConfigId().toString());
}
}
//可用积分会员卡下面是否没有子卡列表
boolean isSubOfAvailableIntegral = CollectionUtils.isEmpty(availabelIntegralSubList);
if (isSubOfAvailableIntegral) {
if (!subSet.contains(availableIntegral)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "数据资产-可用积分不在总积分会员卡及其子卡");
......@@ -259,7 +260,7 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
}
private ServiceResponse validParamValue(String key, String value, Map<String, Boolean> appletCardMap) {
private ServiceResponse validParamValue(String key, String value, Map<String, List<AppletCardDTO>> appletCardMap) {
if (StringUtils.isBlank(value)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), key + "不能为空");
}
......@@ -292,23 +293,21 @@ public class AppletDecorationConfigApiServiceImpl implements AppletDecorationCon
if (appletCardResult.isSuccess()) {
List<MemberCardRelDTO> cardList = appletCardResult.getResult();
List<AppletCardDTO> resultList = new ArrayList<>();
List<AppletCardDTO> subList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(cardList)) {
for (MemberCardRelDTO card : cardList) {
List<MemberCardRelDTO> sub = card.getRelCards();
List<AppletCardDTO> subList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sub)) {
for (MemberCardRelDTO subTemp : sub) {
subList.add(new AppletCardDTO().setCardConfigId(subTemp.getId())
.setCardName(subTemp.getName()).setIsSub(true));
resultList.add(new AppletCardDTO().setCardConfigId(subTemp.getId())
.setCardName(subTemp.getName()).setIsSub(false));
.setCardName(subTemp.getName()));
}
}
resultList.add(new AppletCardDTO().setCardName(card.getName())
.setCardConfigId(card.getId()).setSubList(subList).setIsSub(false));
.setCardConfigId(card.getId()).setSubList(subList));
}
}
return ServiceResponse.success();
return ServiceResponse.success(resultList);
}
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), appletCardResult.getMessage());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment