|
@@ -15,11 +15,9 @@ import org.springframework.stereotype.Service;
|
|
|
import redis.clients.jedis.JedisCluster;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
+import static com.fire.dto.enums.Province.QG_ALL;
|
|
|
import static com.fire.dto.enums.RedisKey.CHILD_ORDER_INFO;
|
|
|
import static com.fire.dto.enums.ValidStatus.SUSPEND;
|
|
|
|
|
@@ -102,21 +100,6 @@ public class DistOrderServiceImpl implements DistOrderService {
|
|
|
//todo 入待发送
|
|
|
return;
|
|
|
}
|
|
|
- //分发组发送次数 这里当分发组找不到合适的产品时 分发组发送次数才加1
|
|
|
- int batchCount = orderInfo.getBatchCount() == null ? 1 : orderInfo.getBatchCount();
|
|
|
- //对分发次数取模确定选择分发组
|
|
|
- int distributeGroupSize = distributeGroups.size();
|
|
|
- //分发组下标 由分发组发送次数-1 取模
|
|
|
- int distributeIndex = (batchCount - 1) % distributeGroupSize;
|
|
|
- //提取到分发组
|
|
|
- DistributeGroup distributeGroup = distributeGroups.get(distributeIndex);
|
|
|
- List<ChannelInfo> channelInfos = distributeGroup.getChannelInfos();
|
|
|
- if (CollectionUtils.isEmpty(channelInfos)) {
|
|
|
- //todo 入待发送
|
|
|
- return;
|
|
|
- }
|
|
|
- //根据分发组策略进行不同的分发操作
|
|
|
- DistributePolicy policy = DistributePolicy.getByCode(distributeGroup.getPolicy());
|
|
|
//分发记录中存的分发日志
|
|
|
Map<Integer, Map<Long, Integer>> recordLog = new HashMap<>();
|
|
|
if (childOrder != null && StringUtils.isEmpty(childOrder.getRecordLog())) {
|
|
@@ -127,26 +110,76 @@ public class DistOrderServiceImpl implements DistOrderService {
|
|
|
log.error("分发记录日志转换异常", e);
|
|
|
}
|
|
|
}
|
|
|
- ChannelInfo change = null;
|
|
|
- //策略
|
|
|
- switch (policy) {
|
|
|
- case COST_PRIOR -> channelInfos.forEach(a -> {
|
|
|
+
|
|
|
+ //分发组发送次数 这里当分发组找不到合适的产品时 分发组发送次数才加1
|
|
|
+ int batchCount = orderInfo.getBatchCount() == null ? 1 : orderInfo.getBatchCount();
|
|
|
+ //选择符合条件的通道产品,存入list中
|
|
|
+ List<ChannelProductInfo> changeProducts = new ArrayList<>();
|
|
|
+ //当取不到分发组通道 或者 通道产品时 分发组发送次数+1
|
|
|
+ while (batchCount <= flowAppInfo.getTotalCount()) {
|
|
|
+ //对分发次数取模确定选择分发组
|
|
|
+ int distributeGroupSize = distributeGroups.size();
|
|
|
+ //分发组下标 由分发组发送次数-1 取模
|
|
|
+ int distributeIndex = (batchCount - 1) % distributeGroupSize;
|
|
|
+ //提取到分发组
|
|
|
+ DistributeGroup distributeGroup = distributeGroups.get(distributeIndex);
|
|
|
+ List<ChannelInfo> channelInfos = distributeGroup.getChannelInfos();
|
|
|
+ if (CollectionUtils.isEmpty(channelInfos)) {
|
|
|
+ batchCount += 1;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //根据分发组策略进行不同的分发操作
|
|
|
+ DistributePolicy policy = DistributePolicy.getByCode(distributeGroup.getPolicy());
|
|
|
+ //当前分发组发送次数的发送记录
|
|
|
+ Map<Long, Integer> thisLog = recordLog.get(batchCount);
|
|
|
+
|
|
|
+ for (ChannelInfo channelInfo : channelInfos) {
|
|
|
+ //已经发送过的通道 直接跳过
|
|
|
+ if (thisLog != null && thisLog.get(channelInfo.getChannelId()) != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
//根据产品价格提取通道
|
|
|
- Map<String, Map<Long, ChannelProductInfo>> productListMap = a.getProductListMap();
|
|
|
+ Map<Long, Map<String, ChannelProductInfo>> productListMap = channelInfo.getProductListMap();
|
|
|
if (productListMap != null) {
|
|
|
- //根据区域提取产品
|
|
|
- Map<Long, ChannelProductInfo> longListMap = productListMap.get(orderInfo.getAreaCode());
|
|
|
- if (longListMap != null) {
|
|
|
- ChannelProductInfo productInfo = longListMap.get(orderInfo.getFlowAmount());
|
|
|
- }
|
|
|
+ //根据面额提取产品
|
|
|
+ Map<String, ChannelProductInfo> strListMap = productListMap.get(orderInfo.getFlowAmount());
|
|
|
+ if (strListMap != null) {
|
|
|
+ //相同面额提取分省和全国资源
|
|
|
+ ChannelProductInfo productInfo = strListMap.get(orderInfo.getAreaCode());
|
|
|
+ //分省资源
|
|
|
+ if (productInfo != null) {
|
|
|
+ changeProducts.add(productInfo);
|
|
|
+ }
|
|
|
+ ChannelProductInfo productInfoAll = strListMap.get(QG_ALL.getCode());
|
|
|
+ if (productInfoAll != null) {
|
|
|
+ changeProducts.add(productInfo);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
- case SPEED_PRIOR -> channelInfos.forEach(a -> {
|
|
|
- a.getChannelId();
|
|
|
- });
|
|
|
-
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(changeProducts)) {
|
|
|
+ batchCount += 1;
|
|
|
+ } else {
|
|
|
+ //如果 取到了产品 那么退出
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //策略
|
|
|
+// switch (policy) {
|
|
|
+// case COST_PRIOR -> {
|
|
|
+//
|
|
|
+// }
|
|
|
+// case SPEED_PRIOR -> {
|
|
|
+// for (ChannelInfo channelInfo : channelInfos) {
|
|
|
+// //根据产品价格提取通道
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
|