Commit e9b7e996 authored by Smile's avatar Smile

会员模块-积分规则 订单V值积分规则重复校验新增客户方规则和是否首单规则更新。

parent 74ef0cae
......@@ -171,10 +171,11 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
private boolean isSameOrderVRule(ScoreRuleOrderVExtraVO oldExtraVO, ScoreRuleOrderVExtraVO extraOrderV) {
return oldExtraVO.getTransportType().equals(extraOrderV.getTransportType()) &&
Objects.equals(oldExtraVO.getFirstOrder(), extraOrderV.getFirstOrder()) &&
verifyFirstOrder(oldExtraVO, extraOrderV) &&
verifyReceiveAddr(oldExtraVO, extraOrderV) &&
verifyChannel(oldExtraVO, extraOrderV) &&
verifyOrderEntry(oldExtraVO.getOrderEntry(), extraOrderV.getOrderEntry());
verifyOrderEntry(oldExtraVO.getOrderEntry(), extraOrderV.getOrderEntry()) &&
verifyCustomerSide(oldExtraVO.getCustomerSide(), extraOrderV.getCustomerSide());
}
private boolean verifyChannel(ScoreRuleOrderVExtraVO oldExtraVO, ScoreRuleOrderVExtraVO extraOrderV) {
......@@ -189,6 +190,13 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
}
return true;
}
private boolean verifyFirstOrder(ScoreRuleOrderVExtraVO oldExtraVO, ScoreRuleOrderVExtraVO extraOrderV) {
// 判断两个是否是不限,其中一个为不限都返回true,否则判断是否相等,不相等返回false
if (oldExtraVO.getFirstOrder() == 2 || extraOrderV.getFirstOrder() == 2) {
return true;
}
return oldExtraVO.getFirstOrder().equals(extraOrderV.getFirstOrder());
}
private boolean verifyReceiveAddr(ScoreRuleOrderVExtraVO oldExtraVO, ScoreRuleOrderVExtraVO extraOrderV) {
List<String> oldReceiveAddrList = Arrays.asList(oldExtraVO.getReceiveAddr().split(","));
......@@ -231,6 +239,20 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
return categorizedSources1.equals(categorizedSources2);
}
private boolean verifyCustomerSide(String oldCustomerSide, String newCustomerSide) {
List<String> oldCustomerSideList = Arrays.asList(oldCustomerSide.split(","));
List<String> newCustomerSideList = Arrays.asList(newCustomerSide.split(","));
// 对订单入口进行归类后比较
Set<String> categorizedSources1 = categorizeCustomerSide(oldCustomerSideList);
Set<String> categorizedSources2 = categorizeCustomerSide(newCustomerSideList);
// 如果一个规则归类为 "ALL",则无论另一个是什么都算相同
if (categorizedSources1.contains("ALL") || categorizedSources2.contains("ALL")) {
return true;
}
// 仅当分类后的集合完全一致时才算相同
return categorizedSources1.equals(categorizedSources2);
}
private Set<String> categorizeOrderEntry(List<String> orderEntrys) {
Set<String> categorizedSources = new HashSet<>();
boolean hasBackend = false;
......@@ -258,6 +280,33 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
return categorizedSources;
}
private Set<String> categorizeCustomerSide(List<String> customerSides) {
Set<String> categorizedSources = new HashSet<>();
boolean hasShipper = false;
boolean hasConsignee = false;
for (String customerSide : customerSides) {
if (customerSide.equals("1")) {
hasShipper = true;
} else if (customerSide.equals("2")) {
hasConsignee = true;
}
}
// 如果同时有后台和客户端,归为 "ALL"
if (hasShipper && hasConsignee) {
categorizedSources.add("ALL");
} else {
if (hasShipper) {
categorizedSources.add("SHIPPER");
}
if (hasConsignee) {
categorizedSources.add("CONSIGNEE");
}
}
return categorizedSources;
}
/**
......
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