|
|
@@ -8,6 +8,7 @@ import com.uas.platform.b2c.logistics.dao.DistributionRuleDao;
|
|
|
import com.uas.platform.b2c.logistics.model.DistributionRule;
|
|
|
import com.uas.platform.b2c.logistics.model.RuleQtyArea;
|
|
|
import com.uas.platform.b2c.logistics.model.RuleQtyFare;
|
|
|
+import com.uas.platform.b2c.logistics.model.UsableRuleInfo;
|
|
|
import com.uas.platform.b2c.logistics.service.DistributionRuleService;
|
|
|
import com.uas.platform.b2c.prod.store.dao.StoreInDao;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
@@ -263,39 +264,56 @@ public class DistributionRuleServiceImpl implements DistributionRuleService{
|
|
|
return distributionRuleDao.findShippingMethodByEnuuAndActive(enuu, ShortConstant.YES_SHORT);
|
|
|
}
|
|
|
|
|
|
- public Map<String, Map<String, Object>> findRuleMatchArea(List<String> uuidArray, String area){
|
|
|
+ /**
|
|
|
+ * 返回所有店铺适用的配送规则
|
|
|
+ * @param uuidArray
|
|
|
+ * @param area
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, List<UsableRuleInfo>> findRuleMatchArea(List<String> uuidArray, String area){
|
|
|
if (area == null){
|
|
|
throw new IllegalOperatorException("地址信息缺失,请重新确认收货地址");
|
|
|
}
|
|
|
+ Map<String, List<UsableRuleInfo>> resultMap = new HashMap<>();
|
|
|
for (String uuid : uuidArray){
|
|
|
- findRuleMatchArea(uuid, area);
|
|
|
+ List<UsableRuleInfo> list = findRuleInStore(uuid, area);
|
|
|
+ resultMap.put(uuid, list);
|
|
|
}
|
|
|
- return null;
|
|
|
+ return resultMap;
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> findRuleMatchArea(String uuid, String area){
|
|
|
+ /**
|
|
|
+ * 返回该店铺适用的配送规则
|
|
|
+ * @param uuid
|
|
|
+ * @param area
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<UsableRuleInfo> findRuleInStore(String uuid, String area){
|
|
|
StoreIn store = storeInDao.findByUuid(uuid);
|
|
|
if (store == null){
|
|
|
- throw new IllegalOperatorException("店铺信息,请刷新后重试");
|
|
|
+ throw new IllegalOperatorException("店铺信息缺失,请刷新后重试");
|
|
|
}
|
|
|
- List<DistributionRule> allRuleList = distributionRuleDao.findAllByEnuu(store.getEnUU());
|
|
|
- List<DistributionRule> ruleList = new ArrayList<>();
|
|
|
+ List<DistributionRule> allRuleList = distributionRuleDao.findByEnuuAndActiveOrderByNumAsc(store.getEnUU(), ShortConstant.YES_SHORT);
|
|
|
+ List<UsableRuleInfo> ruleInfoList = new ArrayList<>();
|
|
|
List<Integer> methodList = new ArrayList<>();
|
|
|
for (DistributionRule rule : allRuleList){
|
|
|
if (!methodList.contains(rule.getShippingMethod())){
|
|
|
List<RuleQtyArea> qtyArea = rule.getAreas();
|
|
|
+ //转化分段地区信息
|
|
|
Map<String, Map<String, List<String>>> resultMap = convertArea(qtyArea);
|
|
|
+ //是否包含改地区信息
|
|
|
boolean isContains = containsArea(resultMap, area);
|
|
|
if (isContains){
|
|
|
methodList.add(rule.getShippingMethod());
|
|
|
+ UsableRuleInfo info = new UsableRuleInfo(rule);
|
|
|
+ ruleInfoList.add(info);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (methodList.size() == 3){
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- return null;
|
|
|
+ return ruleInfoList;
|
|
|
}
|
|
|
|
|
|
/**
|