Parcourir la source

任务提交 数据库查询接入信息和客户产品信息

张均强 il y a 4 ans
Parent
commit
291699f3b0

+ 0 - 1
common/fire-dto/src/main/java/com/fire/dto/CustomerInfo.java

@@ -70,5 +70,4 @@ public class CustomerInfo {
     @ApiModelProperty(value = "跟用户关联,客户登录使用")
     private Integer userId;
 
-
 }

+ 36 - 0
common/fire-dto/src/main/java/com/fire/dto/CustomerProduct.java

@@ -0,0 +1,36 @@
+package com.fire.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel(value = "客户产品表实体")
+@Data
+public class CustomerProduct {
+
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+
+    @ApiModelProperty(value = "客户编号")
+    private Integer customerId;
+
+    @ApiModelProperty(value = "产品(产品表对应的主键)")
+    private Integer productId;
+
+    @ApiModelProperty(value = "产品id")
+    private String packageId;
+
+    @ApiModelProperty(value = "产品类型(1:话费 2:流量)")
+    private Integer type;
+
+    @ApiModelProperty(value = "客户结算价格")
+    private Double price;
+
+    @ApiModelProperty(value = "产品面额")
+    private Double facePrice;
+
+    @ApiModelProperty(value = "是否有效 (0:有效 1:无效)")
+    private String isEffective;
+
+
+}

+ 57 - 0
common/fire-dto/src/main/java/com/fire/dto/FlowAppInfo.java

@@ -0,0 +1,57 @@
+package com.fire.dto;
+
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel(value = "客户接入表实体")
+@Data
+public class FlowAppInfo {
+
+    @ApiModelProperty(value = "接入ID号")
+    private Long flowAppId;
+
+    @ApiModelProperty(value = "客户ID")
+    private Long customerId;
+
+    @ApiModelProperty(value = "应用ID")
+    private String appId;
+
+    @ApiModelProperty(value = "应用Key")
+    private String appKey;
+
+    @ApiModelProperty(value = "开始日期")
+    private Date startDate;
+
+    @ApiModelProperty(value = "结束日期")
+    private Date endDate;
+
+    @ApiModelProperty(value = "1-有效 2-暂停 3-无效")
+    private String status;
+
+    @ApiModelProperty(value = "APP名称")
+    private String appName;
+
+    @ApiModelProperty(value = "回调URL")
+    private String callbackUrl;
+
+    @ApiModelProperty(value = "CPIP地址")
+    private String ipAddress;
+
+    @ApiModelProperty(value = "流量下发通道")
+    private String dispatchChannel;
+
+    @ApiModelProperty(value = "限制发送总次数")
+    private Integer totalCount;
+
+    @ApiModelProperty(value = "限制回调时间")
+    private Integer time;
+
+    @ApiModelProperty(value = "客户基本信息")
+    private CustomerInfo customerInfo;
+
+
+}

+ 15 - 0
modules/make-order/src/main/java/com/fire/order/data/DataPool.java

@@ -0,0 +1,15 @@
+package com.fire.order.data;
+
+import com.fire.dto.FlowAppInfo;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 需要在内存中缓存的信息
+ *
+ * @author ZJQ 2021年5月17日16:14:47
+ */
+public class DataPool {
+    public static Map<String, FlowAppInfo> flowAppInfoMap = new HashMap<>();
+}

+ 5 - 4
modules/make-order/src/main/java/com/fire/order/mapper/CustomerInfoMapper.java

@@ -2,6 +2,8 @@ package com.fire.order.mapper;
 
 import com.fire.dto.CustomerInfo;
 
+import java.util.List;
+
 /**
  * 客户表(CustomerInfo)表数据库访问层
  *
@@ -10,12 +12,11 @@ import com.fire.dto.CustomerInfo;
 public interface CustomerInfoMapper {
 
     /**
-     * 通过ID查询单条数据
+     * 查询所有客户
      *
-     * @param customerId 主键
-     * @return 实例对象
+     * @return CustomerInfo对象list
      */
-    CustomerInfo queryById(Long customerId);
+    List<CustomerInfo> queryAll();
 
 }
 

+ 22 - 0
modules/make-order/src/main/java/com/fire/order/mapper/CustomerProductMapper.java

@@ -0,0 +1,22 @@
+package com.fire.order.mapper;
+
+import com.fire.dto.CustomerProduct;
+
+import java.util.List;
+
+/**
+ * 客户产品表(CustomerProduct)表数据库访问层
+ *
+ * @author ZJQ  2021-05-17 16:47:08
+ */
+public interface CustomerProductMapper {
+
+    /**
+     * 查询所有客户产品
+     *
+     * @return 实例对象
+     */
+    List<CustomerProduct> queryAll();
+
+}
+

+ 25 - 0
modules/make-order/src/main/java/com/fire/order/mapper/FlowAppInfoMapper.java

@@ -0,0 +1,25 @@
+package com.fire.order.mapper;
+
+import com.fire.dto.FlowAppInfo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 客户接入表(FlowAppInfo)表数据库访问层
+ *
+ * @author ZJQ  2021-05-17 14:08:29
+ */
+public interface FlowAppInfoMapper {
+
+    /**
+     * 查询所有接入信息
+     *
+     * @return 实例对象list
+     */
+    List<FlowAppInfo> queryAll();
+
+
+
+}
+

+ 16 - 0
modules/make-order/src/main/java/com/fire/order/service/CustomerService.java

@@ -0,0 +1,16 @@
+package com.fire.order.service;
+
+
+/**
+ * 客户服务层
+ *
+ * @author ZJQ 2021年5月17日15:51:14
+ */
+public interface CustomerService {
+
+    /**
+     * 缓存客户信息
+     */
+    void cacheCustomer();
+
+}

+ 55 - 0
modules/make-order/src/main/java/com/fire/order/service/impl/CustomerServiceImpl.java

@@ -0,0 +1,55 @@
+package com.fire.order.service.impl;
+
+
+import com.fire.dto.CustomerInfo;
+import com.fire.dto.FlowAppInfo;
+import com.fire.order.data.DataPool;
+import com.fire.order.mapper.CustomerInfoMapper;
+import com.fire.order.mapper.FlowAppInfoMapper;
+import com.fire.order.service.CustomerService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 客户服务实现层
+ *
+ * @author ZJQ 2021年5月14日17:13:54
+ */
+@Service
+public class CustomerServiceImpl implements CustomerService {
+
+    @Resource
+    private FlowAppInfoMapper flowAppInfoMapper;
+
+    @Resource
+    private CustomerInfoMapper customerInfoMapper;
+
+    /**
+     * 缓存客户信息
+     */
+    @Override
+    public void cacheCustomer() {
+        //查询所有的客户信息和所有的接入信息
+        List<FlowAppInfo> appInfos = flowAppInfoMapper.queryAll();
+        List<CustomerInfo> customerInfos = customerInfoMapper.queryAll();
+        if (appInfos != null && customerInfos != null) {
+            //将客户信息List 转换为客户id为key的map 如果存在重复key,以后出现的为准
+            Map<Long, CustomerInfo> customerInfoMap = customerInfos.stream().collect(Collectors.toMap(CustomerInfo::getCustomerId, a -> a, (k1, k2) -> k2));
+            //遍历接入信息,将对应客户信息放入接入信息中
+            for (FlowAppInfo appInfo : appInfos) {
+                if (appInfo != null && appInfo.getCustomerId() != null) {
+                    CustomerInfo customerInfo = customerInfoMap.get(appInfo.getCustomerId());
+                    appInfo.setCustomerInfo(customerInfo);
+                }
+            }
+            //将接入信息list 转换为appId为key的map 如果存在重复key,以后出现的为准
+            DataPool.flowAppInfoMap = appInfos.stream().collect(Collectors.toMap(FlowAppInfo::getAppId, a -> a, (k1, k2) -> k2));
+        }
+
+
+    }
+}

+ 8 - 14
modules/make-order/src/main/resources/mapper/CustomerInfoMapper.xml

@@ -25,32 +25,26 @@
         <result property="userId" column="user_id" jdbcType="INTEGER"/>
     </resultMap>
 
-    <!--查询单个-->
-    <select id="queryById" resultMap="CustomerInfoMap">
+    <!--查询全部-->
+    <select id="queryAll" resultMap="CustomerInfoMap">
+        <include refid="baseSql"/>
+    </select>
+
+    <sql id="baseSql">
         select customer_id,
                partner_id,
                customer_name,
                shorter_name,
                linkman_name,
-               linkman_mobile,
-               linkman_email,
-               address,
                status,
                balance,
                credit_amount,
                current_amount,
-               is_first_login,
                is_deleted,
-               creator,
-               create_time,
-               updator,
-               update_time,
                partner_commission,
                user_id
-        from fmp.customer_info
-        where customer_id = #{customerId}
-    </select>
-
+        from customer_info
+    </sql>
 
 </mapper>
 

+ 34 - 0
modules/make-order/src/main/resources/mapper/CustomerProductMapper.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fire.order.mapper.CustomerProductMapper">
+
+    <resultMap type="com.fire.dto.CustomerProduct" id="CustomerProductMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="customerId" column="customer_id" jdbcType="INTEGER"/>
+        <result property="productId" column="product_id" jdbcType="INTEGER"/>
+        <result property="packageId" column="package_id" jdbcType="VARCHAR"/>
+        <result property="type" column="type" jdbcType="INTEGER"/>
+        <result property="price" column="price" jdbcType="NUMERIC"/>
+        <result property="facePrice" column="face_price" jdbcType="NUMERIC"/>
+        <result property="isEffective" column="is_effective" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <!--查询单个-->
+    <select id="queryAll" resultMap="CustomerProductMap">
+        <include refid="baseSql"/>
+    </select>
+
+    <sql id="baseSql">
+        select id,
+               customer_id,
+               product_id,
+               package_id,
+               type,
+               price,
+               face_price,
+               is_effective
+        from customer_product
+    </sql>
+
+</mapper>
+

+ 43 - 0
modules/make-order/src/main/resources/mapper/FlowAppInfoMapper.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fire.order.mapper.FlowAppInfoMapper">
+
+    <resultMap type="com.fire.dto.FlowAppInfo" id="FlowAppInfoMap">
+        <result property="flowAppId" column="flow_app_id" jdbcType="INTEGER"/>
+        <result property="customerId" column="customer_id" jdbcType="INTEGER"/>
+        <result property="appId" column="app_id" jdbcType="VARCHAR"/>
+        <result property="appKey" column="app_key" jdbcType="VARCHAR"/>
+        <result property="startDate" column="start_date" jdbcType="TIMESTAMP"/>
+        <result property="endDate" column="end_date" jdbcType="TIMESTAMP"/>
+        <result property="status" column="status" jdbcType="VARCHAR"/>
+        <result property="appName" column="app_name" jdbcType="VARCHAR"/>
+        <result property="callbackUrl" column="callback_url" jdbcType="VARCHAR"/>
+        <result property="ipAddress" column="ip_address" jdbcType="VARCHAR"/>
+        <result property="dispatchChannel" column="dispatch_channel" jdbcType="VARCHAR"/>
+        <result property="totalCount" column="total_count" jdbcType="INTEGER"/>
+        <result property="time" column="time" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <!--查询全部-->
+    <select id="queryAll" resultMap="FlowAppInfoMap">
+        <include refid="baseSql"/>
+    </select>
+
+    <sql id="baseSql">
+        select flow_app_id,
+               customer_id,
+               app_id,
+               app_key,
+               start_date,
+               end_date,
+               status,
+               app_name,
+               callback_url,
+               ip_address,
+               dispatch_channel,
+               total_count
+        from flow_app_info
+    </sql>
+
+</mapper>
+