zelong.shao

customer|add功能重写

......@@ -5,6 +5,9 @@ import lombok.Data;
@Data
public class ConsignmentAddDto {
/**
* 是否为该用户的运单 1:是 0:否
*/
Integer isCreatorFlag;
Consignment consignment;
}
......
......@@ -28,6 +28,8 @@ public enum ResponseCode {
MESSAGE_CODE_30008(30008,"business_exception_30008"),
MESSAGE_CODE_30009(30009,"business_exception_30009"),
MESSAGE_CODE_30010(30010,"business_exception_30010"),
MESSAGE_CODE_30011(30011,"business_exception_30010"),
MESSAGE_CODE_30012(30012,"business_exception_30012"),
/******打个样,编写样例*****/
// MESSAGE_CODE_30001(30001,"business_exception_30001"),
......
......@@ -8,10 +8,13 @@ import com.fedex.connect.customer.data.bo.ConsignmentBo;
import com.fedex.connect.customer.service.base.BaseService;
import com.fedex.connect.customer.service.biz.IConsignmentService;
import com.fedex.connect.customer.util.service.biz.ConsignmentUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.Objects;
/**
* @Author Szl
* @Description 类说明 运单操作相关service
......@@ -37,15 +40,35 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
public ResponseVo add(ConsignmentBo bo, User user){
//查询运单表是否存在已提交的运单
Consignment consignment = consignmentRepository.findByConsignmentCode(bo.getConsignmentCode());
if (consignment != null && consignment.getId() != null){
//如果存在则进行bo基础校验
consignmentUtil.consignmentCreatorCheck(consignment,bo);
//校验是否是本账号的运单
ResponseVo responseVo = consignmentUtil.consignmentUuidCheck(consignment, user);
return responseVo;
/**
* 不存在则直接返回
*/
if (consignment == null){
if (!StringUtils.isEmpty(bo.getShipperAccount())){
if (Objects.equals(user.getAccountNo(),bo.getShipperAccount())){
return new ResponseUtils().success();
}
}else {
/**
* 不存在运单,并且没有填写shipperAccount,则直接返回
*/
return new ResponseUtils().success();
}
}
/**
* 根据是否是DM501返回不同的提示
*/
if (StringUtils.isEmpty(consignment.getUserUuid())){
/**
* 非501数据
*/
return consignmentUtil.consignmentCheckWithNotCe(consignment,bo,user);
}else {
/**
* 501数据
*/
return consignmentUtil.consignmentCheckWithCe(consignment,bo,user);
}
//如果不存在直接返回
return responseUtils.success();
}
/**
......
......@@ -2,7 +2,6 @@ package com.fedex.connect.customer.util.service.biz;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.model.biz.Consignment;
......@@ -12,6 +11,7 @@ import com.fedex.connect.customer.data.dto.ConsignmentAddDto;
import com.fedex.connect.customer.enums.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
......@@ -32,6 +32,88 @@ public class ConsignmentUtil {
/**
* @Author Szl
* @Description 功能说明 不存在501的运单add时判断该运单是否为自己的运单
* @Date 2024/11/12
* @param consignment
* @param bo
* @param user
* @return void
*/
public ResponseVo consignmentCheckWithNotCe(Consignment consignment, ConsignmentBo bo, User user){
ConsignmentAddDto consignmentAddDto = new ConsignmentAddDto();
consignmentAddDto.setConsignment(consignment);
if (isShipperAccountMatch(bo.getShipperAccount(), consignment.getShipperAccount())){
consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE);
return responseUtils.success(consignmentAddDto);
}else {
return responseUtils.success(ResponseCode.MESSAGE_CODE_30011);
}
}
/**
* @Author Szl
* @Description 功能说明 存在501的运单add时判断该运单是否为自己的运单
* @Date 2024/11/12
* @param consignment
* @param bo
* @param user
* @return void
*/
public ResponseVo consignmentCheckWithCe(Consignment consignment, ConsignmentBo bo, User user) {
ConsignmentAddDto consignmentAddDto = new ConsignmentAddDto();
consignmentAddDto.setConsignment(consignment);
/**
* uuid相同,直接返回所有运单信息
*/
if (Objects.equals(consignment.getUserUuid(), user.getUserUuid())) {
consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE);
return responseUtils.success(consignmentAddDto);
}
/**
* uuid不一致且未填写shipperAccount
*/
if (StringUtils.hasText(bo.getShipperAccount())){
consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_TWO);
return responseUtils.success(ResponseCode.MESSAGE_CODE_30012);
}
/**
* 运单的shipperAccount和用户的shipperAccount一致,则返回提示语+运单信息
*/
if (isShipperAccountMatch(user.getAccountNo(), consignment.getShipperAccount())) {
consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE);
return responseUtils.success(ResponseCode.MESSAGE_CODE_30004, consignmentAddDto);
}
/**
* 录入的shipperAccount和运单的shipperAccount一致,则返回提示语+运单信息
*/
if (isShipperAccountMatch(bo.getShipperAccount(), consignment.getShipperAccount())) {
consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE);
return responseUtils.success(ResponseCode.MESSAGE_CODE_30005, consignmentAddDto);
}
/**
* 都不一致,但是输入了shipperAccount,则给出提示
*/
if (StringUtils.hasText(bo.getShipperAccount())) {
consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_TWO);
return responseUtils.success(ResponseCode.MESSAGE_CODE_30005);
}
return responseUtils.success();
}
// 抽取 ShipperAccount 比较逻辑
private boolean isShipperAccountMatch(String account1, String account2) {
return StringUtils.hasText(account1) && StringUtils.hasText(account2) && account1.equals(account2);
}
/**
* @Author Szl
* @Description 功能说明 校验运单创建人
* @Date 2024/11/5
* @param consignment
......
......@@ -37,4 +37,6 @@ business_exception_30006=附件未上传
business_exception_30007=所有上传文件数量不超过50个文件
business_exception_30008=所有上传文件总大小不超过50M
business_exception_30009=运单或发票未上传
business_exception_30010=文件类型不在:运单、发票、箱单、其他
\ No newline at end of file
business_exception_30010=文件类型不在:运单、发票、箱单、其他
business_exception_30011=该运单已被其他人创建,不可以重复创建
business_exception_30012=UUID不一致
\ No newline at end of file
......
......@@ -37,4 +37,6 @@ business_exception_30006=附件未上传
business_exception_30007=所有上传文件数量不超过50个文件
business_exception_30008=所有上传文件总大小不超过50M
business_exception_30009=运单或发票未上传
business_exception_30010=文件类型不在:运单、发票、箱单、其他
\ No newline at end of file
business_exception_30010=文件类型不在:运单、发票、箱单、其他
business_exception_30011=该运单已被其他人创建,不可以重复创建
business_exception_30012=UUID不一致
\ No newline at end of file
......