Commit 6a2b3a4f authored by 李灿灿's avatar 李灿灿

订单按照测试用例调整

parent 518edf96
...@@ -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})?)$";
......
...@@ -39,13 +39,13 @@ public class OrderConstants { ...@@ -39,13 +39,13 @@ public class OrderConstants {
*/ */
public static final String ORDER_NO_IS_EMPTY = "订单编号不能为空"; public static final String ORDER_NO_IS_EMPTY = "订单编号不能为空";
/** /**
* 回复内容不能为空 * 回复内容和附件,两者必填其一
*/ */
public static final String REPLY_CONTENT_IS_EMPTY = "回复内容不能为空"; public static final String REPLY_CONTENT_AND_ENCLOSURE_IS_EMPTY = "回复内容和附件,两者必填其一";
/** /**
* 附件不能为空 * “回复内容”,200字以内
*/ */
public static final String ENCLOSURE_IS_EMPTY = "附件不能为空"; public static final String REPLY_CONTENT_MORE_THAN_200 = "“回复内容”,200字以内";
/** /**
* 非法的附件类型 * 非法的附件类型
*/ */
......
...@@ -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; package com.yifu.cloud.plus.v1.yifu.order.vo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure; import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
...@@ -20,10 +19,16 @@ import java.util.List; ...@@ -20,10 +19,16 @@ import java.util.List;
public class OrderReplyListVO implements Serializable { public class OrderReplyListVO implements Serializable {
private static final long serialVersionUID = -1376876766552447670L; private static final long serialVersionUID = -1376876766552447670L;
/**
* 主键
*/
@Schema(description = "主键")
private String id;
/** /**
* 订单编号 * 订单编号
*/ */
@JsonIgnore @Schema(description = "订单编号")
private String orderNo; private String orderNo;
/** /**
......
...@@ -18,6 +18,7 @@ import com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderMapper; ...@@ -18,6 +18,7 @@ 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.TOrderEnclosureService;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderReplyService; 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.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;
...@@ -181,64 +182,69 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -181,64 +182,69 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
* @throws IOException * @throws IOException
*/ */
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public R uploadReplyEnclosure(MultipartFile file, String filePath, String replyContent, String orderNo) throws IOException { public R uploadReplyEnclosure(MultipartFile file, String filePath, String replyContent, String orderNo) throws IOException {
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
if (Common.isEmpty(orderNo)){ if (Common.isEmpty(orderNo)){
return R.failed(OrderConstants.ORDER_NO_IS_EMPTY); return R.failed(OrderConstants.ORDER_NO_IS_EMPTY);
} }
if (Common.isEmpty(replyContent)){ if (Common.isEmpty(replyContent) && Common.isEmpty(file)){
return R.failed(OrderConstants.REPLY_CONTENT_IS_EMPTY); return R.failed(OrderConstants.REPLY_CONTENT_AND_ENCLOSURE_IS_EMPTY);
} }
//todo 校验回复内容的长度 // 校验回复内容200字以内
if(Common.isEmpty(file)){ if (!Common.isEmpty(replyContent) && !ValidityUtil.validate200(replyContent)){
return R.failed(OrderConstants.ENCLOSURE_IS_EMPTY); return R.failed(OrderConstants.REPLY_CONTENT_MORE_THAN_200);
} }
if(!Common.checkInsuranceFile(file.getOriginalFilename())){
return R.failed(OrderConstants.ENCLOSURE_TYPE_IS_ERROR); if (!Common.isEmpty(file)){
} if(!Common.checkInsuranceFile(file.getOriginalFilename())){
if (file.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){ return R.failed(OrderConstants.ENCLOSURE_TYPE_IS_ERROR);
return R.failed(OrderConstants.ENCLOSURE_SIZE_ERROR); }
}
String fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename(); if (file.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){
//filePath不传默认存储空间的根目录 return R.failed(OrderConstants.ENCLOSURE_SIZE_ERROR);
//支持的附件格式 }
String key = "";
if (!Common.isNotNull(filePath)) {
key = fileName;
} else {
key = filePath + "/" + fileName;
} }
boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, null);
if (flag) { TOrderReply reply = new TOrderReply();
log.info("文件:" + fileName + "上传至存储空间" + ossUtil.getBucketName() + "成功!"); reply.setOrderNo(orderNo);
TOrderEnclosure orderEnclosure = new TOrderEnclosure(); reply.setReplyContent(Common.isEmpty(replyContent)?null:replyContent);
orderEnclosure.setOrderNo(orderNo); reply.setCreateName(user.getNickname());
orderEnclosure.setEnclosureName(file.getOriginalFilename()); reply.setCreateTime(LocalDateTime.now());
orderEnclosure.setEnclosureFlag(CommonConstants.ONE_INT); reply.setDeleteFlag(CommonConstants.ZERO_INT);
orderEnclosure.setEnclosureAddress(key); boolean save = tOrderReplyService.save(reply);
orderEnclosure.setDeleteFlag(CommonConstants.ZERO_INT); //todo 同步推送ekp
try { if (save && !Common.isEmpty(file)){
boolean b = tOrderEnclosureService.save(orderEnclosure); String fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename();
if (b){ //filePath不传默认存储空间的根目录
TOrderReply reply = new TOrderReply(); //支持的附件格式
reply.setOrderNo(orderNo); String key = "";
reply.setReplyContent(replyContent); if (!Common.isNotNull(filePath)) {
reply.setCreateName(user.getNickname()); key = fileName;
reply.setCreateTime(LocalDateTime.now()); } else {
reply.setDeleteFlag(CommonConstants.ZERO_INT); key = filePath + "/" + fileName;
tOrderReplyService.save(reply); }
//todo 同步推送ekp 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());
} }
} catch (Exception e) { } else {
log.error("OSS文件上传接口异常:" + e.getMessage()); return R.failed(OrderConstants.OPERATE_FAILED);
ossUtil.deleteObject(null, key);
return R.failed("failed:" + e.getMessage());
} }
return R.ok(OrderConstants.OPERATE_SUCCESS);
} else {
return R.failed(OrderConstants.OPERATE_FAILED);
} }
return R.ok(OrderConstants.OPERATE_SUCCESS);
} }
/** /**
...@@ -255,7 +261,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -255,7 +261,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
if (CollectionUtils.isNotEmpty(orderReplyList.getRecords())){ if (CollectionUtils.isNotEmpty(orderReplyList.getRecords())){
orderReplyList.getRecords().stream().forEach(e ->{ orderReplyList.getRecords().stream().forEach(e ->{
List<TOrderEnclosure> list = tOrderEnclosureService.list(Wrappers.<TOrderEnclosure>query().lambda() List<TOrderEnclosure> list = tOrderEnclosureService.list(Wrappers.<TOrderEnclosure>query().lambda()
.eq(TOrderEnclosure::getOrderNo, e.getOrderNo()) .eq(TOrderEnclosure::getOrderNo, e.getId())
.eq(TOrderEnclosure::getEnclosureFlag,CommonConstants.ONE_INT) .eq(TOrderEnclosure::getEnclosureFlag,CommonConstants.ONE_INT)
.eq(TOrderEnclosure::getDeleteFlag,CommonConstants.ZERO_INT) .eq(TOrderEnclosure::getDeleteFlag,CommonConstants.ZERO_INT)
); );
......
...@@ -131,10 +131,11 @@ ...@@ -131,10 +131,11 @@
<select id="getOrderReplyPageList" resultType="com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO"> <select id="getOrderReplyPageList" resultType="com.yifu.cloud.plus.v1.yifu.order.vo.OrderReplyListVO">
select select
t.ORDER_NO as orderNo, t.ID as id,
t.CREATE_NAME as createName, t.ORDER_NO as orderNo,
t.CREATE_TIME as createTime, t.CREATE_NAME as createName,
t.REPLY_CONTENT as replyContent t.CREATE_TIME as createTime,
t.REPLY_CONTENT as replyContent
from t_order_reply t from t_order_reply t
where t.DELETE_FLAG = 0 where t.DELETE_FLAG = 0
and t.ORDER_NO = #{orderNo} and t.ORDER_NO = #{orderNo}
......
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