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,25 +182,39 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -181,25 +182,39 @@ 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.isEmpty(file)){
if(!Common.checkInsuranceFile(file.getOriginalFilename())){ if(!Common.checkInsuranceFile(file.getOriginalFilename())){
return R.failed(OrderConstants.ENCLOSURE_TYPE_IS_ERROR); return R.failed(OrderConstants.ENCLOSURE_TYPE_IS_ERROR);
} }
if (file.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){ if (file.getSize() > (CommonConstants.FIFTY_INT*CommonConstants.BYTE*CommonConstants.BYTE)){
return R.failed(OrderConstants.ENCLOSURE_SIZE_ERROR); 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(); String fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename();
//filePath不传默认存储空间的根目录 //filePath不传默认存储空间的根目录
//支持的附件格式 //支持的附件格式
...@@ -213,33 +228,24 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -213,33 +228,24 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
if (flag) { if (flag) {
log.info("文件:" + fileName + "上传至存储空间" + ossUtil.getBucketName() + "成功!"); log.info("文件:" + fileName + "上传至存储空间" + ossUtil.getBucketName() + "成功!");
TOrderEnclosure orderEnclosure = new TOrderEnclosure(); TOrderEnclosure orderEnclosure = new TOrderEnclosure();
orderEnclosure.setOrderNo(orderNo); orderEnclosure.setOrderNo(reply.getId());
orderEnclosure.setEnclosureName(file.getOriginalFilename()); orderEnclosure.setEnclosureName(file.getOriginalFilename());
orderEnclosure.setEnclosureFlag(CommonConstants.ONE_INT); orderEnclosure.setEnclosureFlag(CommonConstants.ONE_INT);
orderEnclosure.setEnclosureAddress(key); orderEnclosure.setEnclosureAddress(key);
orderEnclosure.setDeleteFlag(CommonConstants.ZERO_INT); orderEnclosure.setDeleteFlag(CommonConstants.ZERO_INT);
try { try {
boolean b = tOrderEnclosureService.save(orderEnclosure); tOrderEnclosureService.save(orderEnclosure);
if (b){
TOrderReply reply = new TOrderReply();
reply.setOrderNo(orderNo);
reply.setReplyContent(replyContent);
reply.setCreateName(user.getNickname());
reply.setCreateTime(LocalDateTime.now());
reply.setDeleteFlag(CommonConstants.ZERO_INT);
tOrderReplyService.save(reply);
//todo 同步推送ekp
}
} catch (Exception e) { } catch (Exception e) {
log.error("OSS文件上传接口异常:" + e.getMessage()); log.error("OSS文件上传接口异常:" + e.getMessage());
ossUtil.deleteObject(null, key); ossUtil.deleteObject(null, key);
return R.failed("failed:" + e.getMessage()); return R.failed("failed:" + e.getMessage());
} }
return R.ok(OrderConstants.OPERATE_SUCCESS);
} else { } else {
return R.failed(OrderConstants.OPERATE_FAILED); 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,6 +131,7 @@ ...@@ -131,6 +131,7 @@
<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.ID as id,
t.ORDER_NO as orderNo, t.ORDER_NO as orderNo,
t.CREATE_NAME as createName, t.CREATE_NAME as createName,
t.CREATE_TIME as createTime, t.CREATE_TIME as createTime,
......
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