Commit e21a52e3 authored by 李灿灿's avatar 李灿灿

Merge branch 'feature-licancan' into 'develop'

Feature licancan

See merge request fangxinjiang/yifu!209
parents 840c989e 56e2dc2d
...@@ -66,6 +66,8 @@ public class ValidityConstants { ...@@ -66,6 +66,8 @@ public class ValidityConstants {
public static final String PATTERN_50 = "^.{1,50}$"; public static final String PATTERN_50 = "^.{1,50}$";
/** 最多60位 规则 */ /** 最多60位 规则 */
public static final String PATTERN_60 = "^.{1,60}$"; public static final String PATTERN_60 = "^.{1,60}$";
/** 最多200位 规则 */
public static final String PATTERN_200 = "^.{1,200}$";
/** 不超过两位小数的正数 */ /** 不超过两位小数的正数 */
public static final String POSITIVE_INTEGER_PATTERN_TWO_FLOAT = "^[+]?([0-9]+(.[0-9]{1,2})?)$"; public static final String POSITIVE_INTEGER_PATTERN_TWO_FLOAT = "^[+]?([0-9]+(.[0-9]{1,2})?)$";
......
...@@ -18,6 +18,10 @@ public class OrderConstants { ...@@ -18,6 +18,10 @@ public class OrderConstants {
* 订单id不可为空 * 订单id不可为空
*/ */
public static final String ORDER_ID_IS_EMPTY = "订单id不可为空"; public static final String ORDER_ID_IS_EMPTY = "订单id不可为空";
/**
* 附件id不可为空
*/
public static final String ENCLOSURE_ID_IS_EMPTY = "附件id不可为空";
/** /**
* 订单已办结,不可操作 * 订单已办结,不可操作
*/ */
...@@ -26,4 +30,28 @@ public class OrderConstants { ...@@ -26,4 +30,28 @@ public class OrderConstants {
* 操作成功 * 操作成功
*/ */
public static final String OPERATE_SUCCESS = "操作成功"; public static final String OPERATE_SUCCESS = "操作成功";
/**
* 操作失败
*/
public static final String OPERATE_FAILED = "操作失败";
/**
* 订单编号不能为空
*/
public static final String ORDER_NO_IS_EMPTY = "订单编号不能为空";
/**
* 回复内容和附件,两者必填其一
*/
public static final String REPLY_CONTENT_AND_ENCLOSURE_IS_EMPTY = "回复内容和附件,两者必填其一";
/**
* “回复内容”,200字以内
*/
public static final String REPLY_CONTENT_MORE_THAN_200 = "“回复内容”,200字以内";
/**
* 非法的附件类型
*/
public static final String ENCLOSURE_TYPE_IS_ERROR = "非法的附件类型";
/**
* 附件超出上传上限
*/
public static final String ENCLOSURE_SIZE_ERROR = "附件超出上传上限";
} }
...@@ -23,12 +23,12 @@ public class TOrderEnclosure implements Serializable { ...@@ -23,12 +23,12 @@ public class TOrderEnclosure implements Serializable {
*/ */
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键") @Schema(description = "主键")
private Integer id; private String id;
/** /**
* 订单编号 * 附件标识是0时是订单编号,1时是回复表id
*/ */
@Schema(description = "订单编号") @Schema(description = "附件标识是0时是订单编号,1时是回复表id")
private String orderNo; private String orderNo;
/** /**
......
...@@ -22,7 +22,7 @@ public class TOrderReply implements Serializable { ...@@ -22,7 +22,7 @@ public class TOrderReply implements Serializable {
*/ */
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键") @Schema(description = "主键")
private Integer id; private String id;
/** /**
* 订单编号 * 订单编号
......
package com.yifu.cloud.plus.v1.yifu.order.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ValidityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
/**
* @author licancan
* @description 校验工具类
* @date 2022-08-30 10:30:16
*/
public class ValidityUtil {
/**
* 验证字符串 最多200位
*
* @author licancan
* @param str
* @return {@link boolean}
*/
public static boolean validate200(final String str){
if(Common.isEmpty(str)){
return Boolean.FALSE;
}
return str.matches(ValidityConstants.PATTERN_200) ;
}
}
package com.yifu.cloud.plus.v1.yifu.order.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author licancan
* @description 订单详情VO
* @date 2022-08-29 15:18:50
*/
@Data
@Schema(description = "订单详情VO")
public class OrderDetailVO implements Serializable {
private static final long serialVersionUID = -6669349004826405691L;
/**
* 创建人姓名(下单人)
*/
@Schema(description = "创建人姓名(下单人)")
private String createName;
/**
* 创建时间(下单时间)
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间(下单时间)")
private LocalDateTime createTime;
/**
* 项目编码
*/
@Schema(description = "项目编码")
private String deptNo;
/**
* 项目名称
*/
@Schema(description = "项目名称")
private String deptName;
/**
* 订单编号
*/
@Schema(description = "订单编号")
private String orderNo;
/**
* 客户名称
*/
@Schema(description = "客户名称")
private String customerName;
/**
* 订单状态 0待办理 1办理中 2已办结
*/
@Schema(description = "订单状态 0待办理 1办理中 2已办结")
private Integer orderStatus;
/**
* 订单内容
*/
@Schema(description = "订单内容")
private String orderContent;
/**
* 原始单据
*/
@Schema(description = "原始单据")
private List<TOrderEnclosure> orderEnclosure;
}
package com.yifu.cloud.plus.v1.yifu.order.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author licancan
* @description 订单回复列表vo
* @date 2022-08-29 17:07:50
*/
@Data
@Schema(description = "订单回复列表vo")
public class OrderReplyListVO implements Serializable {
private static final long serialVersionUID = -1376876766552447670L;
/**
* 主键
*/
@Schema(description = "主键")
private String id;
/**
* 订单编号
*/
@Schema(description = "订单编号")
private String orderNo;
/**
* 创建人姓名(回复人)
*/
@Schema(description = "创建人姓名(回复人)")
private String createName;
/**
* 创建时间(回复时间)
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间(回复时间)")
private LocalDateTime createTime;
/**
* 回复内容
*/
@Schema(description = "回复内容")
private String replyContent;
/**
* 回复附件
*/
@Schema(description = "回复附件")
private List<TOrderEnclosure> orderReplyEnclosure;
}
...@@ -2,19 +2,23 @@ package com.yifu.cloud.plus.v1.yifu.order.controller; ...@@ -2,19 +2,23 @@ package com.yifu.cloud.plus.v1.yifu.order.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.order.constants.OrderConstants;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService; import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
...@@ -71,4 +75,64 @@ public class OrderController { ...@@ -71,4 +75,64 @@ public class OrderController {
return tOrderService.handleOrder(id,status); return tOrderService.handleOrder(id,status);
} }
/**
* 通过id查询详情
*
* @author licancan
* @param id 订单id
* @return {@link R<OrderDetailVO>}
*/
@Operation(summary = "通过id查询详情", description = "通过id查询详情")
@GetMapping("/{id}")
public R<OrderDetailVO> getInsuranceDetailById(@PathVariable("id") String id) {
return tOrderService.getOrderDetailById(id);
}
/**
* 附件预览下载地址
*
* @author licancan
* @param id 附件表id
* @return {@link R}
*/
@Schema(description = "附件预览下载地址,附件表id")
@GetMapping("/getEnclosureUrl/{id}")
public R getEnclosureUrl(@PathVariable String id) {
return tOrderService.getEnclosureUrl(id);
}
/**
* 添加回复
*
* @author licancan
* @param file 附件
* @param filePath 附件路径
* @param replyContent 回复内容
* @param orderNo 订单编号
* @return {@link R}
* @throws IOException
*/
@Schema(description = "添加回复")
@PostMapping(value = "/uploadReplyEnclosure")
public R uploadReplyEnclosure(@RequestBody MultipartFile file, String filePath, String replyContent,String orderNo) throws IOException {
return tOrderService.uploadReplyEnclosure(file, filePath,replyContent,orderNo);
}
/**
* 订单回复列表分页查询
*
* @author licancan
* @param page
* @param orderNo
* @return {@link R<IPage< OrderReplyListVO>>}
*/
@Operation(summary = "订单回复列表分页查询", description = "订单回复列表分页查询")
@GetMapping("/getOrderReplyPageList")
public R<IPage<OrderReplyListVO>> getOrderReplyPageList(Page<OrderReplyListVO> page, String orderNo) {
if (Common.isEmpty(orderNo)){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
}
return R.ok(tOrderService.getOrderReplyPageList(page,orderNo));
}
} }
...@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder; import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -47,4 +49,23 @@ public interface TOrderMapper extends BaseMapper<TOrder> { ...@@ -47,4 +49,23 @@ public interface TOrderMapper extends BaseMapper<TOrder> {
* @return {@link List< OrderListVO>} * @return {@link List< OrderListVO>}
*/ */
List<OrderListVO> getOrderList(@Param("param") OrderListParam param); List<OrderListVO> getOrderList(@Param("param") OrderListParam param);
/**
* 通过id查询详情
*
* @author licancan
* @param id
* @return {@link OrderDetailVO}
*/
OrderDetailVO getOrderDetailById(@Param("id") String id);
/**
* 订单回复列表分页查询
*
* @author licancan
* @param page
* @param orderNo
* @return {@link IPage< OrderReplyListVO>}
*/
IPage<OrderReplyListVO> getOrderReplyPageList(Page<OrderReplyListVO> page,@Param("orderNo") String orderNo);
} }
...@@ -6,9 +6,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -6,9 +6,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder; import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
...@@ -46,4 +50,45 @@ public interface TOrderService extends IService<TOrder> { ...@@ -46,4 +50,45 @@ public interface TOrderService extends IService<TOrder> {
* @return {@link R<String>} * @return {@link R<String>}
*/ */
R<String> handleOrder(String id, Integer status); R<String> handleOrder(String id, Integer status);
/**
* 通过id查询详情
*
* @author licancan
* @param id
* @return {@link R<OrderDetailVO>}
*/
R<OrderDetailVO> getOrderDetailById(String id);
/**
* 附件预览下载地址
*
* @author licancan
* @param id 附件表id
* @return {@link R}
*/
R getEnclosureUrl(String id);
/**
* 添加回复
*
* @author licancan
* @param file 附件
* @param filePath 附件路径
* @param replyContent 回复内容
* @param orderNo 订单编号
* @return {@link R}
* @throws IOException
*/
R uploadReplyEnclosure(MultipartFile file, String filePath, String replyContent, String orderNo) throws IOException;
/**
* 订单回复列表分页查询
*
* @author licancan
* @param page
* @param orderNo
* @return {@link IPage< OrderReplyListVO>}
*/
IPage<OrderReplyListVO> getOrderReplyPageList(Page<OrderReplyListVO> page, String orderNo);
} }
package com.yifu.cloud.plus.v1.yifu.order.service.impl; package com.yifu.cloud.plus.v1.yifu.order.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.order.constants.OrderConstants; import com.yifu.cloud.plus.v1.yifu.order.constants.OrderConstants;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder; import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderReply;
import com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderMapper; import com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderMapper;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderEnclosureService;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderReplyService;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService; import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService;
import com.yifu.cloud.plus.v1.yifu.order.util.ValidityUtil;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
/** /**
...@@ -31,6 +47,12 @@ import java.util.Optional; ...@@ -31,6 +47,12 @@ import java.util.Optional;
@Slf4j @Slf4j
@Service @Service
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService { public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService {
@Resource
private TOrderEnclosureService tOrderEnclosureService;
@Resource
private TOrderReplyService tOrderReplyService;
@Resource
private OSSUtil ossUtil;
/** /**
* 订单列表分页查询 * 订单列表分页查询
...@@ -77,7 +99,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -77,7 +99,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
if (StringUtils.isEmpty(id)){ if (StringUtils.isEmpty(id)){
return R.failed(OrderConstants.ORDER_ID_IS_EMPTY); return R.failed(OrderConstants.ORDER_ID_IS_EMPTY);
} }
if (CommonConstants.TWO_INT != status && CommonConstants.THREE_INT != status){ if (CommonConstants.ONE_INT != status && CommonConstants.TWO_INT != status){
return R.failed(OrderConstants.STATUS_ERROR); return R.failed(OrderConstants.STATUS_ERROR);
} }
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
...@@ -85,7 +107,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -85,7 +107,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
if (!Optional.ofNullable(byId).isPresent()){ if (!Optional.ofNullable(byId).isPresent()){
return R.failed(OrderConstants.DATA_IS_EMPTY); return R.failed(OrderConstants.DATA_IS_EMPTY);
} }
if (CommonConstants.THREE_INT == byId.getOrderStatus()){ if (CommonConstants.TWO_INT == byId.getOrderStatus()){
return R.failed(OrderConstants.ORDER_IS_HANDLED); return R.failed(OrderConstants.ORDER_IS_HANDLED);
} }
byId.setOrderStatus(status); byId.setOrderStatus(status);
...@@ -93,7 +115,164 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -93,7 +115,164 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
byId.setUpdateName(user.getNickname()); byId.setUpdateName(user.getNickname());
byId.setUpdateTime(LocalDateTime.now()); byId.setUpdateTime(LocalDateTime.now());
this.updateById(byId); this.updateById(byId);
// todo 如果是办结完成同步给ekp
return R.ok(OrderConstants.OPERATE_SUCCESS); return R.ok(OrderConstants.OPERATE_SUCCESS);
} }
/**
* 通过id查询详情
*
* @param id
* @return {@link R<OrderDetailVO>}
* @author licancan
*/
@Override
public R<OrderDetailVO> getOrderDetailById(String id) {
if (StringUtils.isEmpty(id)){
return R.failed(OrderConstants.ORDER_ID_IS_EMPTY);
}
OrderDetailVO orderDetailVO = this.baseMapper.getOrderDetailById(id);
//处理订单附件
if (Optional.ofNullable(orderDetailVO).isPresent()){
List<TOrderEnclosure> list = tOrderEnclosureService.list(Wrappers.<TOrderEnclosure>query().lambda()
.eq(TOrderEnclosure::getOrderNo, orderDetailVO.getOrderNo())
.eq(TOrderEnclosure::getEnclosureFlag,CommonConstants.ZERO_INT)
.eq(TOrderEnclosure::getDeleteFlag,CommonConstants.ZERO_INT)
);
if (CollectionUtils.isNotEmpty(list)){
orderDetailVO.setOrderEnclosure(list);
}else {
orderDetailVO.setOrderEnclosure(Lists.newArrayList());
}
}
return R.ok(orderDetailVO);
}
/**
* 附件预览下载地址
*
* @param id 附件表id
* @return {@link R}
* @author licancan
*/
@Override
public R getEnclosureUrl(String id) {
if(StringUtils.isEmpty(id)){
return R.failed(OrderConstants.ENCLOSURE_ID_IS_EMPTY);
}
TOrderEnclosure orderEnclosure = tOrderEnclosureService.getById(id);
if (!Optional.ofNullable(orderEnclosure).isPresent()) {
return R.failed(OrderConstants.DATA_IS_EMPTY);
}
String enclosureAddress = orderEnclosure.getEnclosureAddress();
log.info("key:"+enclosureAddress);
URL url = ossUtil.getObjectUrl(null, orderEnclosure.getEnclosureAddress());
return new R<>(url.toString());
}
/**
* 添加回复
*
* @author licancan
* @param file 附件
* @param filePath 附件路径
* @param replyContent 回复内容
* @param orderNo 订单编号
* @return {@link R}
* @throws IOException
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R uploadReplyEnclosure(MultipartFile file, String filePath, String replyContent, String orderNo) throws IOException {
YifuUser user = SecurityUtils.getUser();
if (Common.isEmpty(orderNo)){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
}
if (Common.isEmpty(replyContent) && Common.isEmpty(file)){
return R.failed(OrderConstants.REPLY_CONTENT_AND_ENCLOSURE_IS_EMPTY);
}
// 校验回复内容200字以内
if (!Common.isEmpty(replyContent) && !ValidityUtil.validate200(replyContent)){
return R.failed(OrderConstants.REPLY_CONTENT_MORE_THAN_200);
}
if (!Common.isEmpty(file)){
if(!Common.checkInsuranceFile(file.getOriginalFilename())){
return R.failed(OrderConstants.ENCLOSURE_TYPE_IS_ERROR);
}
if (file.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){
return R.failed(OrderConstants.ENCLOSURE_SIZE_ERROR);
}
}
TOrderReply reply = new TOrderReply();
reply.setOrderNo(orderNo);
reply.setReplyContent(Common.isEmpty(replyContent)?null:replyContent);
reply.setCreateName(user.getNickname());
reply.setCreateTime(LocalDateTime.now());
reply.setDeleteFlag(CommonConstants.ZERO_INT);
boolean save = tOrderReplyService.save(reply);
//todo 同步推送ekp
if (save && !Common.isEmpty(file)){
String fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename();
//filePath不传默认存储空间的根目录
//支持的附件格式
String key = "";
if (!Common.isNotNull(filePath)) {
key = fileName;
} else {
key = filePath + "/" + fileName;
}
boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, null);
if (flag) {
log.info("文件:" + fileName + "上传至存储空间" + ossUtil.getBucketName() + "成功!");
TOrderEnclosure orderEnclosure = new TOrderEnclosure();
orderEnclosure.setOrderNo(reply.getId());
orderEnclosure.setEnclosureName(file.getOriginalFilename());
orderEnclosure.setEnclosureFlag(CommonConstants.ONE_INT);
orderEnclosure.setEnclosureAddress(key);
orderEnclosure.setDeleteFlag(CommonConstants.ZERO_INT);
try {
tOrderEnclosureService.save(orderEnclosure);
} catch (Exception e) {
log.error("OSS文件上传接口异常:" + e.getMessage());
ossUtil.deleteObject(null, key);
return R.failed("failed:" + e.getMessage());
}
} else {
return R.failed(OrderConstants.OPERATE_FAILED);
}
}
return R.ok(OrderConstants.OPERATE_SUCCESS);
}
/**
* 订单回复列表分页查询
*
* @param page
* @param orderNo
* @return {@link IPage<OrderReplyListVO>}
* @author licancan
*/
@Override
public IPage<OrderReplyListVO> getOrderReplyPageList(Page<OrderReplyListVO> page, String orderNo) {
IPage<OrderReplyListVO> orderReplyList = baseMapper.getOrderReplyPageList(page,orderNo);
if (CollectionUtils.isNotEmpty(orderReplyList.getRecords())){
orderReplyList.getRecords().stream().forEach(e ->{
List<TOrderEnclosure> list = tOrderEnclosureService.list(Wrappers.<TOrderEnclosure>query().lambda()
.eq(TOrderEnclosure::getOrderNo, e.getId())
.eq(TOrderEnclosure::getEnclosureFlag,CommonConstants.ONE_INT)
.eq(TOrderEnclosure::getDeleteFlag,CommonConstants.ZERO_INT)
);
if (CollectionUtils.isNotEmpty(list)){
e.setOrderReplyEnclosure(list);
}else {
e.setOrderReplyEnclosure(Lists.newArrayList());
}
});
}
return orderReplyList;
}
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<mapper namespace="com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderEnclosureMapper"> <mapper namespace="com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderEnclosureMapper">
<resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure"> <resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure">
<id property="id" column="ID" jdbcType="INTEGER"/> <id property="id" column="ID" jdbcType="VARCHAR"/>
<result property="orderNo" column="ORDER_NO" jdbcType="VARCHAR"/> <result property="orderNo" column="ORDER_NO" jdbcType="VARCHAR"/>
<result property="enclosureName" column="ENCLOSURE_NAME" jdbcType="VARCHAR"/> <result property="enclosureName" column="ENCLOSURE_NAME" jdbcType="VARCHAR"/>
<result property="remark" column="REMARK" jdbcType="VARCHAR"/> <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
......
...@@ -115,4 +115,31 @@ ...@@ -115,4 +115,31 @@
ORDER BY t.ORDER_STATUS,t.CREATE_TIME DESC ORDER BY t.ORDER_STATUS,t.CREATE_TIME DESC
</select> </select>
<select id="getOrderDetailById" resultType="com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO">
select
t.CREATE_NAME as createName,
t.CREATE_TIME as createTime,
t.DEPT_NO as deptNo,
t.DEPT_NAME as deptName,
t.ORDER_NO as orderNo,
t.CUSTOMER_NAME as customerName,
t.ORDER_STATUS as orderStatus,
t.ORDER_CONTENT as orderContent
from t_order t
where t.ID = #{id}
</select>
<select id="getOrderReplyPageList" resultType="com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO">
select
t.ID as id,
t.ORDER_NO as orderNo,
t.CREATE_NAME as createName,
t.CREATE_TIME as createTime,
t.REPLY_CONTENT as replyContent
from t_order_reply t
where t.DELETE_FLAG = 0
and t.ORDER_NO = #{orderNo}
ORDER BY t.CREATE_TIME DESC
</select>
</mapper> </mapper>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<mapper namespace="com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderReplyMapper"> <mapper namespace="com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderReplyMapper">
<resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.order.entity.TOrderReply"> <resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.order.entity.TOrderReply">
<id property="id" column="ID" jdbcType="INTEGER"/> <id property="id" column="ID" jdbcType="VARCHAR"/>
<result property="orderNo" column="ORDER_NO" jdbcType="VARCHAR"/> <result property="orderNo" column="ORDER_NO" jdbcType="VARCHAR"/>
<result property="replyContent" column="REPLY_CONTENT" jdbcType="VARCHAR"/> <result property="replyContent" column="REPLY_CONTENT" jdbcType="VARCHAR"/>
<result property="createName" column="CREATE_NAME" jdbcType="VARCHAR"/> <result property="createName" column="CREATE_NAME" jdbcType="VARCHAR"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment