Browse Source

接收广电保存原始数据

mac 2 years ago
parent
commit
618e499b17

+ 192 - 0
kxs-product/kxs-product-api/src/main/java/com/kxs/product/api/model/KxsGdOrder.java

@@ -0,0 +1,192 @@
+package com.kxs.product.api.model;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 广电推送订单信息表(KxsGdOrder)表实体类
+ *
+ * @author 系统
+ * @since 2024-06-19 12:36:35
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class KxsGdOrder extends Model<KxsGdOrder> implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    
+    
+    /**
+     * 主键ID
+     */
+    @Schema(description = "主键ID")
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+
+    /**
+     * 新增时间
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @Schema(description = "新增时间")
+    private LocalDateTime createTime;
+
+
+    /**
+     * 更新时间
+     */
+    @TableField(fill = FieldFill.UPDATE)
+    @Schema(description = "更新时间")
+    private LocalDateTime updateTime;
+
+
+    /**
+     * 删除标记,0未删除,1已删除
+     */
+    @Schema(description = "删除标记,0未删除,1已删除")
+    private Integer delFlag;
+
+
+    /**
+     * 版本
+     */
+    @Schema(description = "版本")
+    private Integer version;
+
+
+    /**
+     * 广电sn
+     */
+    @Schema(description = "广电sn")
+    private String iccid;
+
+
+    /**
+     * 首充金额
+     */
+    @Schema(description = "首充金额")
+    private BigDecimal firstRechargeAmount;
+
+
+    /**
+     * 产品名称
+     */
+    @Schema(description = "产品名称")
+    private String productName;
+
+
+    /**
+     * 省份
+     */
+    @Schema(description = "省份")
+    private String province;
+
+
+    /**
+     * 城市
+     */
+    @Schema(description = "城市")
+    private String city;
+
+
+    /**
+     * 入网姓名
+     */
+    @Schema(description = "入网姓名")
+    private String userName;
+
+
+    /**
+     * 备注
+     */
+    @Schema(description = "备注")
+    private String remark;
+
+
+    /**
+     * 状态 1 订单生成2 订单正在运行3 待发货4 配送中5 订单成功结束6 已激活成功11 办理失败12 拒签13 订单取消中14 订单取消
+     */
+    @Schema(description = "状态")
+    private Integer status;
+
+
+    /**
+     * 广电手机号码
+     */
+    @Schema(description = "广电手机号码")
+    private String gdMobile;
+
+
+    /**
+     * 广电订单号
+     */
+    @Schema(description = "广电订单号")
+    private String orderNo;
+
+
+    /**
+     * 快递公司
+     */
+    @Schema(description = "快递公司")
+    private String erpName;
+
+
+    /**
+     * 快递单号
+     */
+    @Schema(description = "快递单号")
+    private String erpNo;
+
+
+    /**
+     * 身份证号
+     */
+    @Schema(description = "身份证号")
+    private String idcardNo;
+
+
+    /**
+     * 收货人
+     */
+    @Schema(description = "收货人")
+    private String receiveName;
+
+
+    /**
+     * 收货手机号
+     */
+    @Schema(description = "收货手机号")
+    private String receiveMobile;
+
+
+    /**
+     * 收货详细地址
+     */
+    @Schema(description = "收货详细地址")
+    private String address;
+
+
+    /**
+     * 详细地址
+     */
+    @Schema(description = "详细地址")
+    private String addressDetail;
+
+
+
+
+}
+

+ 17 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/mapper/KxsGdOrderMapper.java

@@ -0,0 +1,17 @@
+package com.kxs.product.biz.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.kxs.product.api.model.KxsGdOrder;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 广电推送订单信息表(KxsGdOrder)表数据库访问层
+ *
+ * @author 系统
+ * @since 2024-06-19 12:36:35
+ */
+@Mapper
+public interface KxsGdOrderMapper extends BaseMapper<KxsGdOrder> {
+
+}
+

+ 15 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/KxsGdOrderService.java

@@ -0,0 +1,15 @@
+package com.kxs.product.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.kxs.product.api.model.KxsGdOrder;
+
+/**
+ * 广电推送订单信息表(KxsGdOrder)表服务接口
+ *
+ * @author 系统
+ * @since 2024-06-19 12:36:35
+ */
+public interface KxsGdOrderService extends IService<KxsGdOrder> {
+
+}
+

+ 19 - 0
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/impl/KxsGdOrderServiceImpl.java

@@ -0,0 +1,19 @@
+package com.kxs.product.biz.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.kxs.product.biz.mapper.KxsGdOrderMapper;
+import com.kxs.product.api.model.KxsGdOrder;
+import com.kxs.product.biz.service.KxsGdOrderService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 广电推送订单信息表(KxsGdOrder)表服务实现类
+ *
+ * @author 系统
+ * @since 2024-06-19 12:36:35
+ */
+@Service("kxsGdOrderService")
+public class KxsGdOrderServiceImpl extends ServiceImpl<KxsGdOrderMapper, KxsGdOrder> implements KxsGdOrderService {
+
+}
+

+ 75 - 36
kxs-product/kxs-product-biz/src/main/java/com/kxs/product/biz/service/impl/KxsGdServiceImpl.java

@@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.kxs.common.core.exception.GlobalCustomerException;
 import com.kxs.common.mq.handlers.IMQSender;
+import com.kxs.product.api.model.KxsGdOrder;
 import com.kxs.product.api.model.KxsGdReport;
 import com.kxs.product.api.req.gd.GdQueryCardOrderReq;
 import com.kxs.product.api.res.gd.GdCommRes;
@@ -22,13 +23,16 @@ import com.kxs.product.api.amqp.rabbit.RabbitGdActQueueMQ;
 import com.kxs.product.biz.config.RsaProperties;
 import com.kxs.product.biz.constant.enums.GdReportEnum;
 import com.kxs.product.biz.mapper.KxsGdReportMapper;
+import com.kxs.product.biz.service.KxsGdOrderService;
 import com.kxs.product.biz.service.KxsGdService;
 import com.kxs.product.biz.util.GdRsaUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
@@ -51,6 +55,8 @@ public class KxsGdServiceImpl implements KxsGdService {
 
     private final IMQSender mqSender;
 
+    private final KxsGdOrderService gdOrderService;
+
     @Async("getAsyncExecutor")
     @Override
     public void checkGdAsyncData(String startTime, String endTime) {
@@ -91,6 +97,7 @@ public class KxsGdServiceImpl implements KxsGdService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void checkGdAsyncData(Map<String, Object> param) {
 
         JSONArray dataList = JSON.parseArray(param.get("data").toString());
@@ -106,49 +113,81 @@ public class KxsGdServiceImpl implements KxsGdService {
         } catch (Exception e) {
             throw new GlobalCustomerException("广电接收激活数据验证签名失败");
         }
+
         for (Object obj : dataList) {
             JSONObject orderData = JSON.parseObject(obj.toString());
-            //订单流转接口,暂不处理
-            if (!orderData.containsKey("status") || !orderData.containsKey("mobile")) {
-                continue;
-            }
-            //1 订单生成2 订单正在运行3 待发货4 配送中5 订单成功结束6 已激活成功11 办理失败12 拒签13 订单取消中14 订单取消
-            int status = orderData.getInteger("status");
-            if(status != 6){
-                continue;
-            }
-            String gdMobile = orderData.getString("mobile");
-            if(StrUtil.isBlank(gdMobile)){
-                continue;
-            }
-            KxsGdReport kxsGdReport = kxsGdReportMapper.selectOne(Wrappers.<KxsGdReport>lambdaQuery()
-                    .eq(KxsGdReport::getIsCheck, GdReportEnum.CHECK_NO.getType())
-                    .eq(KxsGdReport::getGdMobile, gdMobile));
-            if (kxsGdReport == null) {
-                return;
+            //订单信息
+            if("1".equals(param.get("type").toString())){
+
+                KxsGdOrder kxsGdOrder = gdOrderService.getOne(Wrappers.<KxsGdOrder>lambdaQuery().eq(KxsGdOrder::getOrderNo, orderData.getString("orderNo")));
+                if(kxsGdOrder == null){
+                    kxsGdOrder = new KxsGdOrder();
+                }
+                kxsGdOrder.setIccid(orderData.getString("iccid"));
+                kxsGdOrder.setFirstRechargeAmount(new BigDecimal(orderData.getString("firstRechargeAmount")));
+                kxsGdOrder.setProductName(orderData.getString("productName"));
+                kxsGdOrder.setProvince(orderData.getString("province"));
+                kxsGdOrder.setCity(orderData.getString("city"));
+                kxsGdOrder.setUserName(orderData.getString("userName"));
+                kxsGdOrder.setGdMobile(orderData.getString("mobile"));
+                kxsGdOrder.setOrderNo(orderData.getString("orderNo"));
+                kxsGdOrder.setErpName(orderData.getString("logisticsCompany"));
+                kxsGdOrder.setErpNo(orderData.getString("logisticsNo"));
+                kxsGdOrder.setIdcardNo(orderData.getString("idcardNo"));
+                kxsGdOrder.setReceiveName(orderData.getString("receiveName"));
+                kxsGdOrder.setReceiveMobile(orderData.getString("receiveMobile"));
+                kxsGdOrder.setAddress(orderData.getString("receiveAddress"));
+                kxsGdOrder.setAddressDetail(orderData.getString("receiveAddressDetail"));
+                kxsGdOrder.setCreateTime(LocalDateTimeUtil.parse(orderData.getString("createTime"), DatePattern.NORM_DATETIME_PATTERN));
+                gdOrderService.saveOrUpdate(kxsGdOrder);
             }
+            //激活状态
+            if("2".equals(param.get("type").toString())){
+                String orderNo = orderData.getString("orderNo");
+                //1 订单生成2 订单正在运行3 待发货4 配送中5 订单成功结束6 已激活成功11 办理失败12 拒签13 订单取消中14 订单取消
+                String status = orderData.getString("status");
+                KxsGdOrder kxsGdOrder = gdOrderService.getOne(Wrappers.<KxsGdOrder>lambdaQuery().eq(KxsGdOrder::getOrderNo, orderNo));
+                if (kxsGdOrder == null) {
+                    continue;
+                }
+                kxsGdOrder.setStatus(Integer.valueOf(status));
+                gdOrderService.updateById(kxsGdOrder);
+                //激活成功
+                if("6".equals(status)){
+                    KxsGdReport kxsGdReport = kxsGdReportMapper.selectOne(Wrappers.<KxsGdReport>lambdaQuery()
+                            .eq(KxsGdReport::getIsCheck, GdReportEnum.CHECK_NO.getType())
+                            .eq(KxsGdReport::getGdMobile, kxsGdOrder.getGdMobile()));
+                    if (kxsGdReport == null) {
+                        continue;
+                    }
+                    kxsGdReport.setStatus(GdReportEnum.CHECK_SUC.getType());
+                    kxsGdReportMapper.updateById(kxsGdReport);
+                    toSendMq(kxsGdOrder, kxsGdReport.getGdSn());
+                }
 
-            RabbitGdActQueueMQ.MsgEntity msgEntity = new RabbitGdActQueueMQ.MsgEntity();
-            msgEntity.setPosSn(orderData.getString("iccid"));
-            msgEntity.setPhoneNo(orderData.getString("mobile"));
-            msgEntity.setProductName(orderData.getString("productName"));
-            msgEntity.setActivationStatusName("已激活");
-            msgEntity.setPromotionName(orderData.getString("offerName"));
-            msgEntity.setProvince(orderData.getString("province"));
-            msgEntity.setCity(orderData.getString("city"));
-            msgEntity.setOrderCreateTime(orderData.getString("createTime"));
-            msgEntity.setActivationTime(LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.NORM_DATETIME_PATTERN));
-
-            mqSender.send(RabbitGdActQueueMQ.build(msgEntity));
-
-            kxsGdReportMapper.update(null, Wrappers.<KxsGdReport>lambdaUpdate().eq(KxsGdReport::getId, kxsGdReport.getId())
-                    .set(KxsGdReport::getIsCheck, GdReportEnum.CHECK_SUC.getType())
-                    .set(KxsGdReport::getGdMobile, gdMobile));
-            log.info("发送电渠广电激活数据{}", kxsGdReport.getGdSn()
-                    + "," + kxsGdReport.getGdMobile());
+            }
         }
     }
 
+    private void toSendMq(KxsGdOrder order, String sn){
+        RabbitGdActQueueMQ.MsgEntity msgEntity = new RabbitGdActQueueMQ.MsgEntity();
+        msgEntity.setPosSn(sn);
+        msgEntity.setPhoneNo(order.getGdMobile());
+        msgEntity.setProductName(order.getProductName());
+        msgEntity.setActivationStatusName("已激活");
+        msgEntity.setPromotionName(order.getProductName());
+        msgEntity.setProvince(order.getProvince());
+        msgEntity.setCity(order.getCity());
+        msgEntity.setInitialChargeAmount(order.getFirstRechargeAmount());
+        msgEntity.setOrderCreateTime(LocalDateTimeUtil.format(order.getCreateTime(), DatePattern.NORM_DATETIME_PATTERN));
+        msgEntity.setActivationTime(LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.NORM_DATETIME_PATTERN));
+
+        mqSender.send(RabbitGdActQueueMQ.build(msgEntity));
+
+        log.info("发送电渠广电激活数据{}", sn
+                + "," + order.getGdMobile());
+    }
+
 
     public List<GdQueryOrderRes.GdQueryOrder> queryCardOrders(String startTime, String endTime, int pageNo, int pageSize) {
 

+ 31 - 0
kxs-product/kxs-product-biz/src/main/resources/mapper/KxsGdOrderMapper.xml

@@ -0,0 +1,31 @@
+<?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.kxs.product.biz.mapper.KxsGdOrderMapper">
+
+    <resultMap type="com.kxs.product.api.model.KxsGdOrder" id="KxsGdOrderMap">
+        <result column="id" property="id" />
+        <result column="create_time" property="createTime" />
+        <result column="update_time" property="updateTime" />
+        <result column="del_flag" property="delFlag" />
+        <result column="version" property="version" />
+        <result column="iccid" property="iccid" />
+        <result column="first_recharge_amount" property="firstRechargeAmount" />
+        <result column="product_name" property="productName" />
+        <result column="province" property="province" />
+        <result column="city" property="city" />
+        <result column="user_name" property="userName" />
+        <result column="remark" property="remark" />
+        <result column="status" property="status" />
+        <result column="gd_mobile" property="gdMobile" />
+        <result column="order_no" property="orderNo" />
+        <result column="erp_name" property="erpName" />
+        <result column="erp_no" property="erpNo" />
+        <result column="idcard_no" property="idcardNo" />
+        <result column="receive_name" property="receiveName" />
+        <result column="receive_mobile" property="receiveMobile" />
+        <result column="address" property="address" />
+        <result column="address_detail" property="addressDetail" />
+
+    </resultMap>
+
+</mapper>