|
@@ -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;
|
|
|
+ }
|
|
|
}
|