Explorar el Código

bug修改 tomap的value不能为空

张均强 hace 4 años
padre
commit
485d1da9f5

+ 2 - 2
common/fire-dto/src/main/java/com/fire/dto/ChannelInfo.java

@@ -80,9 +80,9 @@ public class ChannelInfo {
     private Integer distributeGroupId;
 
     @TableField(exist = false)
-    @ApiModelProperty(value = "通道产品 根据通道id分第一层 根据区域分第二次 根据面额分第三层", hidden = true)
+    @ApiModelProperty(value = "通道产品 根据通道id分第一层 根据面额分第二次 根据区域分第三层", hidden = true)
     @JsonIgnoreProperties
-    Map<String, Map<Long, ChannelProductInfo>> productListMap;
+    Map<Long, Map<String, ChannelProductInfo>> productListMap;
 
     @ApiModelProperty("供应商名称")
     @TableField(exist = false)

+ 2 - 2
modules/distribution/src/main/java/com/fire/dist/service/impl/CacheServiceImpl.java

@@ -90,8 +90,8 @@ public class CacheServiceImpl implements CacheService {
         List<ChannelGroup> channelGroups = channelGroupMapper.queryAll();
 
         if (CollectionUtils.isNotEmpty(productInfos) && CollectionUtils.isNotEmpty(channelInfos) && CollectionUtils.isNotEmpty(distributeGroups) && CollectionUtils.isNotEmpty(channelGroups)) {
-            //通道产品 根据 通道id第一层 区域第二层 面额分第三层 进行分组
-            Map<Long, Map<String, Map<Long, ChannelProductInfo>>> productListMap = productInfos.stream().filter(a -> a.getChannelId() != null && !StringUtils.isEmpty(a.getAreaNum()) && a.getFacePrice() != null).collect(Collectors.groupingBy(ChannelProductInfo::getChannelId, Collectors.groupingBy(ChannelProductInfo::getAreaNum, Collectors.toMap(ChannelProductInfo::getFacePrice, a -> a, (k1, k2) -> k2))));
+            //通道产品 根据 通道id第一层 面额第二层 区域分第三层 进行分组
+            Map<Long, Map<Long, Map<String, ChannelProductInfo>>> productListMap = productInfos.stream().filter(a -> a.getChannelId() != null && !StringUtils.isEmpty(a.getAreaNum()) && a.getFacePrice() != null && a.getPrice() != null).collect(Collectors.groupingBy(ChannelProductInfo::getChannelId, Collectors.groupingBy(ChannelProductInfo::getFacePrice, Collectors.toMap(ChannelProductInfo::getAreaNum, a -> a, (k1, k2) -> k2))));
             //将产品挂载到通道上面
             channelInfos.forEach(a -> a.setProductListMap(productListMap.get(a.getChannelId())));
             //通道按分发组id进行分组

+ 67 - 34
modules/distribution/src/main/java/com/fire/dist/service/impl/DistOrderServiceImpl.java

@@ -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) {
+//                    //根据产品价格提取通道
+//
+//                }
+//            }
+//
+//        }
     }
 
 

+ 2 - 2
modules/distribution/src/main/resources/bootstrap.yml

@@ -13,11 +13,11 @@ spring:
   cloud:
     nacos:
       config:
-        server-addr: 192.168.2.114:8848
+        server-addr: 47.106.133.48:8848
         file-extension: yaml
         namespace: fire
       discovery:
-        server-addr: 192.168.2.114:8848
+        server-addr: 47.106.133.48:8848
         namespace: fire
         service: distribution
 ---

+ 0 - 12
modules/distribution/src/main/resources/mapper/ChannelInfoMapper.xml

@@ -31,11 +31,6 @@
                a.ip,
                a.discount,
                a.channel_type,
-               a.succ_num,
-               a.fail_num,
-               a.succ_ratio,
-               a.timly_rate,
-               a.total_succ_ratio,
                a.is_delete,
                b.distribute_group_id
         from access_channel_info a
@@ -55,14 +50,7 @@
                update_time,
                ip,
                discount,
-               is_allow_sale,
-               is_sms_notice,
                channel_type,
-               succ_num,
-               fail_num,
-               succ_ratio,
-               timly_rate,
-               total_succ_ratio,
                is_delete
         from access_channel_info
     </sql>

+ 2 - 2
modules/distribution/src/main/resources/mapper/ChannelProductInfoMapper.xml

@@ -8,7 +8,7 @@
         <result property="productId" column="product_id" jdbcType="VARCHAR"/>
         <result property="productName" column="product_name" jdbcType="VARCHAR"/>
         <result property="packageId" column="package_id" jdbcType="VARCHAR"/>
-        <result property="standardPrice" column="standard_price" jdbcType="INTEGER"/>
+        <result property="facePrice" column="face_price" jdbcType="INTEGER"/>
         <result property="price" column="price" jdbcType="NUMERIC"/>
         <result property="remark" column="remark" jdbcType="VARCHAR"/>
         <result property="isValid" column="is_valid" jdbcType="INTEGER"/>
@@ -23,7 +23,7 @@
                a.product_id,
                a.product_name,
                a.package_id,
-               a.standard_price,
+               a.face_price,
                a.price,
                a.remark,
                a.is_valid,

+ 1 - 1
modules/make-order/src/main/java/com/fire/order/request/OrderRequestContent.java

@@ -37,6 +37,6 @@ public class OrderRequestContent {
 
     @ApiModelProperty(value = "结算价格")
     @JsonProperty(value = "PRICE")
-    private Integer price;
+    private Long price;
 
 }

+ 2 - 0
modules/make-order/src/main/java/com/fire/order/rest/MakeOrderRest.java

@@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 
+import static com.fire.common.constants.RocketTopic.UPDATE_TOPIC;
+
 /**
  * 下单接口rest类
  *

+ 2 - 1
modules/make-order/src/main/java/com/fire/order/service/impl/CacheServiceImpl.java

@@ -12,6 +12,7 @@ import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -86,7 +87,7 @@ public class CacheServiceImpl implements CacheService {
     public void cacheBlacklist() {
         List<BlacklistPhone> phones = blacklistPhoneMapper.queryAll();
         if (CollectionUtils.isNotEmpty(phones)) {
-            DataPool.blackList = phones.stream().collect(Collectors.toMap(BlacklistPhone::getPhoneNo, BlacklistPhone::getNote, (k1, k2) -> k2));
+            DataPool.blackList = phones.stream().collect(Collectors.toMap(BlacklistPhone::getPhoneNo, s -> Optional.ofNullable(s.getNote()).orElse("黑名单"), (k1, k2) -> k2));
         }
     }