Explorar o código

增加飞书订单回调

xda %!s(int64=2) %!d(string=hai) anos
pai
achega
c488fac399

+ 8 - 9
src/main/java/com/winhc/repal/entity/RepalOrder.java

@@ -1,21 +1,20 @@
 package com.winhc.repal.entity;
 
-import java.math.BigDecimal;
-import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
-
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
 /**
  * @description RepalOrder实体对象
  * @author Generator
@@ -23,9 +22,9 @@ import org.springframework.format.annotation.DateTimeFormat;
  */
 @Data
 @Accessors(chain = true)
-@TableName("REPAL_ORDER")
+@TableName("REPAL_BUY_ORDER")
 @ApiModel(value="RepalOrder实体对象", description="回款宝订单表")
-public class RepalOrder implements Serializable {
+public class RepalBuyOrder implements Serializable {
 
     private static final long serialVersionUID = 1L;
 

+ 13 - 0
src/main/java/com/winhc/repal/repository/RepalBuyOrderMapper.java

@@ -0,0 +1,13 @@
+package com.winhc.repal.repository;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.winhc.repal.entity.RepalBuyOrder;
+
+/**
+ * @description RepalBuyOrder Mapper 接口
+ * @author Generator
+ * @date 2022-06-13
+ */
+public interface RepalBuyOrderMapper extends BaseMapper<RepalBuyOrder> {
+
+}

+ 0 - 13
src/main/java/com/winhc/repal/repository/RepalOrderMapper.java

@@ -1,13 +0,0 @@
-package com.winhc.repal.repository;
-
-import com.winhc.repal.entity.RepalOrder;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-
-/**
- * @description RepalOrder Mapper 接口
- * @author Generator
- * @date 2022-06-13
- */
-public interface RepalOrderMapper extends BaseMapper<RepalOrder> {
-
-}

+ 16 - 0
src/main/java/com/winhc/repal/service/RepalBuyOrderService.java

@@ -0,0 +1,16 @@
+package com.winhc.repal.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.winhc.repal.entity.RepalBuyOrder;
+
+
+/**
+ * @description RepalBuyOrder 接口类
+ * @author Generator
+ * @date 2022-04-08
+ */
+public interface RepalBuyOrderService extends IService<RepalBuyOrder> {
+
+
+
+}

+ 25 - 7
src/main/java/com/winhc/repal/service/RepalOrderService.java

@@ -1,15 +1,33 @@
 package com.winhc.repal.service;
 
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.winhc.repal.entity.RepalOrder;
-
+import com.winhc.common.model.base.VOPage;
+import com.winhc.repal.model.dto.RepalOrderPageDTO;
+import com.winhc.repal.model.vo.RepalOrderVO;
 
 /**
- * @description RepalOrder 接口类
- * @author Generator
- * @date 2022-06-13
+ * @Description: RepalOrderService
+ * @Author: xda
+ * @Date: 2022/5/19 19:48
  */
-public interface RepalOrderService extends IService<RepalOrder> {
+public interface RepalOrderService {
+
+
+    /**
+     * 获取回款宝订单
+     * @param dto dto
+     * @return com.winhc.common.model.base.VOPage<com.winhc.repal.model.vo.RepalOrderVO>
+     * @author xda
+     * @date 2022/5/19 20:14
+     */
+    VOPage<RepalOrderVO> getRepalOrderPage(RepalOrderPageDTO dto);
 
 
+    /**
+     * 获取短信催款详情
+     * @param orderId orderId
+     * @return com.winhc.repal.model.vo.RepalOrderVO
+     * @author xda
+     * @date 2022/5/22 09:05
+     */
+    RepalOrderVO getSmsDetail(String orderId);
 }

+ 5 - 5
src/main/java/com/winhc/repal/service/impl/CallbackServiceImpl.java

@@ -2,11 +2,11 @@ package com.winhc.repal.service.impl;
 
 import com.winhc.common.enums.CodeMsg;
 import com.winhc.common.exception.CommonException;
-import com.winhc.repal.entity.RepalOrder;
+import com.winhc.repal.entity.RepalBuyOrder;
 import com.winhc.repal.enums.FsBuyTypeEnum;
 import com.winhc.repal.model.dto.FsCallbackDTO;
 import com.winhc.repal.service.CallbackService;
-import com.winhc.repal.service.RepalOrderService;
+import com.winhc.repal.service.RepalBuyOrderService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -22,13 +22,13 @@ import java.util.Objects;
 public class CallbackServiceImpl implements CallbackService {
 
     @Autowired
-    private RepalOrderService repalOrderService;
+    private RepalBuyOrderService repalBuyOrderService;
 
     @Override
     public Boolean processFsOrderCallback(FsCallbackDTO dto) {
-        RepalOrder repalOrder = new RepalOrder();
+        RepalBuyOrder repalOrder = new RepalBuyOrder();
         BeanUtils.copyProperties(dto, repalOrder);
-        repalOrderService.save(repalOrder);
+        repalBuyOrderService.save(repalOrder);
         // 订单处理
         FsBuyTypeEnum fsBuyTypeEnum = FsBuyTypeEnum.getEnumByCode(dto.getBuyType());
         if (Objects.isNull(fsBuyTypeEnum)) {

+ 18 - 0
src/main/java/com/winhc/repal/service/impl/RepalBuyOrderServiceImpl.java

@@ -0,0 +1,18 @@
+package com.winhc.repal.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.winhc.repal.entity.RepalBuyOrder;
+import com.winhc.repal.repository.RepalBuyOrderMapper;
+import com.winhc.repal.service.RepalBuyOrderService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @description RepalBuyOrderService 接口实现类
+ * @author Generator
+ * @date 2022-04-08
+ */
+@Service
+public class RepalBuyOrderServiceImpl extends ServiceImpl<RepalBuyOrderMapper, RepalBuyOrder> implements RepalBuyOrderService {
+
+
+}

+ 124 - 7
src/main/java/com/winhc/repal/service/impl/RepalOrderServiceImpl.java

@@ -1,17 +1,134 @@
 package com.winhc.repal.service.impl;
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.winhc.repal.entity.RepalOrder;
-import com.winhc.repal.repository.RepalOrderMapper;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.module.login.usersession.UserBean;
+import com.winhc.common.base.BeanResponse;
+import com.winhc.common.model.base.VOPage;
+import com.winhc.repal.cloud.WinCoinService;
+import com.winhc.repal.cloud.vo.WinCoinOrderFormVO;
+import com.winhc.repal.enums.RepalDynamicTypeEnum;
+import com.winhc.repal.model.dto.RepalOrderPageDTO;
+import com.winhc.repal.model.vo.RepalLinkVO;
+import com.winhc.repal.model.vo.RepalOrderVO;
+import com.winhc.repal.service.RepalDynamicService;
 import com.winhc.repal.service.RepalOrderService;
+import com.winhc.repal.util.UserContextUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
+
 /**
- * @description RepalOrder 接口实现类
- * @author Generator
- * @date 2022-06-13
+ * @Description: RepalOrderServiceImpl
+ * @Author: xda
+ * @Date: 2022/5/19 19:48
  */
 @Service
-public class RepalOrderServiceImpl extends ServiceImpl<RepalOrderMapper, RepalOrder> implements RepalOrderService {
+public class RepalOrderServiceImpl implements RepalOrderService {
+
+    @Autowired
+    private RepalDynamicService repalDynamicService;
+
+    @Autowired
+    private WinCoinService winCoinService;
+
+    @Override
+    public VOPage<RepalOrderVO> getRepalOrderPage(RepalOrderPageDTO dto) {
+        dto.setUserId(UserContextUtil.getUser().getUserId());
+        VOPage<RepalOrderVO> voPage = new VOPage<>();
+        voPage.setPageNum(dto.getPageNum());
+        voPage.setPageSize(dto.getPageSize());
+        BeanResponse<VOPage<WinCoinOrderFormVO>> beanResponse = winCoinService.getRepalOrderPage(dto);
+        if (Objects.isNull(beanResponse) || Objects.isNull(beanResponse.getBody()) || CollUtil.isEmpty(beanResponse.getBody().getDataList())) {
+            return voPage;
+        }
+        voPage.setTotalPage(beanResponse.getBody().getTotalPage());
+        voPage.setTotalNum(beanResponse.getBody().getTotalNum());
+        List<RepalOrderVO> voList = new ArrayList<>();
+        for (WinCoinOrderFormVO orderFormVO : beanResponse.getBody().getDataList()) {
+            RepalOrderVO vo = new RepalOrderVO();
+            LocalDateTime.parse(DateUtil.format(orderFormVO.getOrderTime(), "yyyy-MM-dd HH:mm:ss"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+            vo.setOrderTime(LocalDateTime.parse(DateUtil.format(orderFormVO.getOrderTime(), "yyyy-MM-dd HH:mm:ss"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+            vo.setOrderId(orderFormVO.getOrderId());
+            vo.setStatus(orderFormVO.getStatus());
+            Map<String, String> map = JSONObject.parseObject(orderFormVO.getGoodsJson(), new TypeReference<HashMap<String, String>>(){});
+            // 短信催款
+            if ("sms_repal".equals(orderFormVO.getProductCode())) {
+                vo.setOrderType(RepalDynamicTypeEnum.短信.getCode());
+                vo.setCustName(String.valueOf(map.get("company")));
+                List<RepalLinkVO> links = JSONObject.parseObject(map.get("links"), new TypeReference<List<RepalLinkVO>>(){});
+                if (CollUtil.isNotEmpty(links)) {
+                    vo.setLinkman(links.stream().map(RepalLinkVO::getName).collect(Collectors.joining(",")));
+                }
+            }
+            // 律师函
+            if ("303".equals(orderFormVO.getProductCode())) {
+                vo.setOrderType(RepalDynamicTypeEnum.律师函.getCode());
+                vo.setCustName(String.valueOf(map.get("company")));
+                List<RepalLinkVO> links = JSONObject.parseObject(map.get("links"), new TypeReference<List<RepalLinkVO>>(){});
+                if (CollUtil.isNotEmpty(links)) {
+                    vo.setLinkman(links.stream().map(RepalLinkVO::getName).collect(Collectors.joining(",")));
+                }
+            }
+            // 咨询
+            if ("phone_consult".equals(orderFormVO.getProductCode())) {
+                vo.setOrderType(RepalDynamicTypeEnum.咨询.getCode());
+                vo.setServiceDesc(map.get("serviceDesc"));
+                vo.setServiceType(Integer.valueOf(map.get("serviceType")));
+                vo.setLawyerServiceSubType(Integer.valueOf(map.get("lawyerServiceSubType")));
+                vo.setLawyerServiceType(Integer.valueOf(map.get("lawyerServiceType")));
+            }
+            // 诉讼
+            if ("203".equals(orderFormVO.getProductCode()) || "205".equals(orderFormVO.getProductCode())) {
+                vo.setOrderType(RepalDynamicTypeEnum.诉讼.getCode());
+                vo.setServiceDesc(map.get("serviceDesc"));
+                if (StrUtil.isNotBlank(map.get("lawyerServiceSubType"))) {
+                    vo.setLawyerServiceSubType(Integer.valueOf(map.get("lawyerServiceSubType")));
+                }
+                if (StrUtil.isNotBlank(map.get("lawyerServiceType"))) {
+                    vo.setLawyerServiceType(Integer.valueOf(map.get("lawyerServiceType")));
+                }
+                vo.setCaseAmtStr(map.get("caseAmt"));
+                if (StrUtil.isNotBlank(map.get("caseStage"))) {
+                    vo.setCaseStage(Integer.valueOf(map.get("caseStage")));
+                }
+            }
+            voList.add(vo);
+        }
+        voPage.setDataList(voList);
+        return voPage;
+    }
+
+    @Override
+    public RepalOrderVO getSmsDetail(String orderId) {
+        UserBean userBean = new UserBean();
+        userBean.setUserId(UserContextUtil.getUser().getUserId());
+        BeanResponse<WinCoinOrderFormVO> beanResponse = winCoinService.getOrderForm(JSON.toJSONString(userBean), orderId);
+        if (Objects.isNull(beanResponse) || Objects.isNull(beanResponse.getBody())) {
+            return null;
+        }
+        RepalOrderVO vo = new RepalOrderVO();
+        LocalDateTime.parse(DateUtil.format(beanResponse.getBody().getOrderTime(), "yyyy-MM-dd HH:mm:ss"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 
+        vo.setOrderTime(LocalDateTime.parse(DateUtil.format(beanResponse.getBody().getOrderTime(), "yyyy-MM-dd HH:mm:ss"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+        vo.setOrderId(beanResponse.getBody().getOrderId());
+        vo.setStatus(beanResponse.getBody().getStatus());
+        vo.setOrderType("sms_repal".equals(beanResponse.getBody().getProductCode()) ? RepalDynamicTypeEnum.短信.getCode() : RepalDynamicTypeEnum.律师函.getCode());
+        Map<String, String> map = JSONObject.parseObject(beanResponse.getBody().getGoodsJson(), new TypeReference<HashMap<String, String>>(){});
+        vo.setCustName(String.valueOf(map.get("company")));
+        List<RepalLinkVO> links = JSONObject.parseObject(map.get("links"), new TypeReference<List<RepalLinkVO>>(){});
+        if (CollUtil.isNotEmpty(links)) {
+            vo.setLinks(links);
+        }
+        vo.setSmsDesc(map.get("content"));
+        return vo;
+    }
 }

+ 1 - 1
src/main/resources/mapper/RepalOrderMapper.xml

@@ -1,5 +1,5 @@
 <?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.winhc.repal.repository.RepalOrderMapper">
+<mapper namespace="com.winhc.repal.repository.RepalBuyOrderMapper">
 
 </mapper>